0

I Have Ajax code That Performs window.location = "free-listing-new.php"; And Code is as follow

For some reason i cant use <form action="">.

$("#submitnumber1").submit(function(){

        if ($("#cmobile1").val() != "" && $("#user_selected_country").val() != "" && $("#cmobile1").val().length > 8) 
        {
          var mynumber = $("#cmobile1").val();
          var userCountry = $("#user_selected_country").val();
          //Ajax Call
          $.ajax({
              type : "POST",
              url : "ajax/ajax-send-otp.php",
              data : {mynumber:mynumber,userCountry:userCountry},
              success : function(data) {
                if(data == 2){
                  window.location = "free-listing-new.php";
                }else{
                  alert("Error : " + data);
                }
              }
          });
        }
});

And Html is

<form  method="post" action="" id="submitnumber1">
</form>

Now On Form Submit If Data is 2 Than user should redict to desire page(free-listing) But it cant.php

1 Answers1

0

Try adding "return false" to your submit-eventhandler.

Andre Nuechter
  • 2,141
  • 11
  • 19