Very strange jQuery / AJAX behavior
- by Dr. DOT
I have an Ajax call to the server that only works when I pass an alert(); to it. Cannot figure out what is wrong. Can anyone help?
This Does Not Work (ie., Ajax call to server does not get made):
<!--
jQuery.support.cors = true; // needed for ajax to work in certain older browsers and versions
$('input[name="status"]').on("change", function() {
if ($('input:radio[name="status"]:checked').val() == 'Y') {
$.ajax({
url: 'http://mydomain.com/dir/myPHPscript.php?param=' + $('#param').val() + '&id=' + ( $('#id').val() * 1 ) + '&mode=' + $('#mode').val()
});
}
window.parent.closePP();
window.top.location.href = $('#redirect').val(); // reloads page
});
//-->
This Works! (ie., Ajax call to server gets made when I have the alert() present):
<!--
jQuery.support.cors = true; // needed for ajax to work in certain older browsers and versions
$('input[name="status"]').on("change", function() {
if ($('input:radio[name="status"]:checked').val() == 'Y') {
$.ajax({
url: 'http://mydomain.com/dir/myPHPscript.php?param=' + $('#param').val() + '&id=' + ( $('#id').val() * 1 ) + '&mode=' + $('#mode').val()
});
**alert('this makes it work');**
}
window.parent.closePP();
window.top.location.href = $('#redirect').val(); // reloads page
});
//-->
Thanks.