[jQuery] jQuery Form ajaxForm submit to webservice gets redirected to web service URL output
Hello,
If anyone can help with this I'd really appreciate it.
I am using the jQuery Form plugin to submit the contents of a Form via
Ajax to a Web Service. The Web service resides on a different domain
to the main site.
I simply want to submit the form info to the web service via Ajax,
check the return value from the Web Service and on success then re-
direct the user to a "Thanks for registering" page. The current
behaviour is that the form is submitted successfully but instead of my
success function being called the page is instead re-directed to the
Web Service output (XML !). I can get the beforeSubmit event to fire,
but I cannot get the Web Service output to return to the calling page.
example page :
http://qpr.sitekit.net/registration.html?RequestedResourceURL=Linking%20Business%20Strategy%20with%20Process%20Excellence.pdf
code as follows:
///INCLUDE JQUERY HERE
<script type="text/javascript">
$(document).ready(function(){
$(".ReturningVisitor").yav({
errorDiv:"mainRVError",
errorMessage:"Please enter the email address you used at first
registration"
});
$(".MainRegistration").yav({
errorDiv:"mainError",
errorMessage:"Please complete all required fields and provide a
valid email address"
});
$("#Country").selectOptions(":::countrycodefromip:::");
var AJAXoptions = {
target: '.output1', // target element(s) to be updated
with server response
beforeSubmit: showRequest, // pre-submit callback
success: showResponse, // post-submit callback
dataType: 'xml',
resetForm : true,
url: 'http://194.100.185.35/leadws/QPRCrmService.asmx/NewLead'
};
//Assign AJAX handler to form
$(".MainRegistration").ajaxForm(AJAXoptions);
});
// pre-submit callback
function showRequest(formData, jqForm, options) {
var queryString = $.param(formData);
alert('About to submit: \n\n' + queryString);
return true;
}
// post-submit callback
//THIS IS NEVER CALLED !
function showResponse(responseText, statusText) {
alert('status: ' + statusText + '\n\nresponseText: \n' +
responseText +
'\n\nThe output div should have already been updated with the
responseText.');
}
</script>