Reputation: 5761
The following jQuery validation works well, however there is sth wrong within the AJAX call as it return unsuccessful. Full code here http://jsfiddle.net/YJwsZ/6/
I am quite new with AJAX as well.
I would like the following to return successful:
// AJAX call
$.ajax({
url:url_site,
data : data,
// dataType: 'json',
type: 'post',
success: function(r){
if (r.success) {
alert('success');
}
else {
alert('unsuccessful');
}
}
});
Upvotes: 0
Views: 116
Reputation: 2377
Try to rebuild your ajax call and add the success callback as a chained function. You also might want to create a little php script that actually answers your testcase. See the docs!
$.ajax({
url: url_site,
data: data,
// dataType: 'json',
type: 'post',
}).done(function(data, textStatus, jqXHR) {
alert(textStatus);
})
.fail(function(jqXHR, textStatus, errorThrown) {
alert(textStatus);
})
.always(function(dataOrJqXHR, textStatus, jqXHRorErrorThrown) {
alert('callback after ' + textStatus + ' callback has been completed');
});
Upvotes: 1
Reputation: 8350
It's probably unsuccessful because url_site is not setup correctly. Re-check your path to the file you are trying to connect to. Use an absolute path if you just can't get a relative location working for you.
Upvotes: 0