I\'m validating for duplicate names by using jquery+Ajax. Everything is working fine except that the form is not submitting once everything returns true
What
We had the same problem and think we sorted out.
The thing is that the .submit() action doesn't work inside the "thread" $.ajax neither $.post.
For that you have to add the async:false instruction inside the $.ajax block and submit the form when the $.ajax execution finishes.
Not tested but this is the working idea:
html:
javacript:
function Mycheck() {
var result = "";
$.ajax {
async:false,
url: you_url_here,
timeout: 15000,
success: function(data) {
result="success";
},
error: function(request, status, err) {
result="error";
}
};
// Here, if success -> SUBMIT FORM or whatever
// Only get here if "ASYNC" = FALSE!!!
if (result == "success") {
$("form").submit(); // this submits the form
return;
} else {
alert('error');
// the form will not be post
}
}