I have a problem with ajaxSubmit... The problem is that, when I submit a form and get a response from PHP that have a script with window.location, the page doesn't change at all...
My PHP script just returns a script with window.location when the form is submitted correctly, otherwise, it returns a JSON that is parsed on the success function.
Using the tools of Chrome, I see that it loads the window.location URL on the Network Tab but, it doesn't show it to the user...
Here's the code I have:
$("form").submit(function(e) {
e.preventDefault();
$("form").ajaxSubmit({
success: function(resp){
try{
resp=JSON.parse(resp);
alert(resp["error"]);
} catch(e){
$("<div></div>").html(resp);
}
}
});
return false;
});
How do I need to do to make it work? Is there any property of options parameter of AjaxSubmit that could solve that?
Just provide URL without JS code in your server answer and then execute :
$("form").submit(function(e) {
e.preventDefault();
$("form").ajaxSubmit({
success: function(resp){
try{
resp=JSON.parse(resp);
window.location.href = resp;
} catch(e){
$("<div></div>").html(resp);
}
}
});
return false;
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With