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!
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!