I’m working on a form validation and submission using jQuery and AJAX. Now, most of it is working perfectly. Just a small snippet that’s getting in the way:
alert ('Validation success');
jQuery.post(
jQuery(this).attr('action'),
jQuery(this).serialize(),
function(response) {
alert('display thank you');
},
'json'
);
return false;
The post is working. ‘Validation success’ is shown, the form is submitted, the data is stored in the database and the e-mail is sent. But… the alert afterwards (‘display thank you’) isn’t showing. Which means I can’t show the ‘thank you’-message.
It’s probably something small and stupid, but I’ve been staring at it for hours and I just can’t find it, so it’d be great if someone can help me out. Thanks.
jQuery only calls the success function if the response code is in the 200 range or 304 AND the response is of the type that jQuery is expecting.
I presume you’re getting a 200 response code, but is the response valid json?