Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do i process serialized data with Javascript and ASP? 1

Status
Not open for further replies.

Jouster

Programmer
Dec 4, 2000
82
0
0
US
Im not sure if this is the right forum, but here it goes.

Im using ajax code to submit serialized data to my server side webpage:

$(document).on('pageinit', '#login', function() {
$(document).on('click', '#submit', function() { // catch the form's submit event
if($('#fname').val().length > 0 && $('#pfpass').val().length > 0){
// Send data to server through the ajax call
// action is functionality we want to call and outputJSON is our data
$.ajax({url: 'logmein.asp',
data: {action : 'login', formData : $('#check-user').serialize()},
type: 'post',
async: 'true',
dataType: 'json',
//contentType: 'application/json',
beforeSend: function() {
// This callback function will trigger before data is sent
$.mobile.showPageLoadingMsg(true); // This will show ajax spinner

},
complete: function() {
// This callback function will trigger on data sent/received complete
$.mobile.hidePageLoadingMsg(); // This will hide ajax spinner
},
success: function (result) {
alert(result.foo);
if(result.status=="true") {
alert('Logon successful');
$.mobile.changePage("#second");
} else {
alert('Logon unsuccessful!');
}
},
error: function (request,error) {
// This callback function will trigger on unsuccessful action
alert('Network error has occurred please try again!');
alert(request.responseText);

}
});
} else {
alert('Please fill all necessary fields');
}
return false; // cancel original event to prevent form submitting*/
});
});

on my server side web page I don't know how to access the form values.

If I do a Request.Form() I get: Action=login&formData=fname%3Dfoo%26pfpass%3Dbar
If I do a Request.Form('formData') I get: formData=fname%3Dfoo%26pfpass%3Dbar

I'm not sure how to access the values. I suppose it needs to be deserialzed but I can't figure out how with javascript and ASP.
Does anyone have an example of this?

Thanks!
 
Your string does not look serialized, merely url encoded. If you decode it you get:

formData=fname=foo&pfpass=bar


This is unrelated to Ajax, as decoding it would be done at the server by ASP.

You'll likely get more specific answers in forum333 or forum855






----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Web & Tech
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top