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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access serialized form data with javascript and ASP

Status
Not open for further replies.

Jouster

Programmer
Dec 4, 2000
82
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=foo&pfpass=bar
If I do a Request.Form('formData') I get: formData=fname=foo&pfpass=bar

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!



 
Do you mean javascript or jquery.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top