$("#register").submit(function(e){ e.preventDefault(); $.ajax({ type: "POST", url: "App/ajax/register.php", data: $(this).serialize(), success: function(data){ $("#nresult").html(data); if(data.includes("success")){ window.location = "home"; } } }); });