I’m calling the JavaScript function onsubmit of form but form has submit before finished the submit function.If I use the alert in the onsubmit function it finish the function first then submit the form.I used the settimeout function in place of alert but it didn’t work.How can I submit the form after the onsubmit has complete.
function chat1close(name){
var abc;
abc=window.frames[0].test();
$.ajax({
type:'GET',
url:'modules/closechat.php?abc='+abc+'&name='+name,
success:function(data){
}
});
document.getElementById("hello").innerHTML=" ";
alert("yes");
return true;
}
Add
async: falseto your ajax call. This will prevent it from executing the rest of the function until the call returns.