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:

demo here


Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -