Try something like this? Using the success
, error
or complete
functions of ajax?
$(document).ready(function(){
$('input[name="status"]').on("change", function() {
if ($('input:radio[name="status"]:checked').val() == 'Y')
{
$.ajax({
type: "GET",
url: "http://mydomain.com/ajax/serverScript.php",
data: "action=" + $('#action').val() + "&id=" + ( $('#id').val() * 1 ) + "&mode=" + $('#mode').val(),
success: function(d)
{
// do something with the result d?
window.parent.closePP();
window.top.location.href = $('#redirect').val();
},
error: function()
{
// do something when the call goes wrong?
},
complete: function()
{
// do something when the call finishes, either successful or not?
}
});
}
});
});