ajax redirect issue -
i want redirect form after ( success ) page. use code
$(document).ready(function(){ $("#ajax-form").submit(function(){ $.post( "ajaxcontact/ajax-register.php", $("#ajax-form").serialize(), function(data){ if (data.success) $("span#ajax-message").css({'color':'green'}); window.location("index.html"); else $("span#ajax-message").css({'color':'red'}); $("span#ajax-message").html(data.message); }, "json" ); return false; });
});
how redirect.
regards
if want redirect page there, should work:
if(data.success) window.location = "url";
updated:
$(document).ready(function() { $("#ajax-form").submit(function() { $.post("ajaxcontact/ajax-register.php", $("#ajax-form").serialize(), function(data) { if (data.success) { //if successful... window.location = 'http://www.google.com'; } else { //if unsuccessful... alert("post unsuccessful."); } },"json"); return false; }); });
that should work long post returning successfully. here's demo using confirm imitate post:
Comments
Post a Comment