Login page returns json on first submit but 2nd logs in correct

i have the following script for a login page on my system

<script>
	
$("#callAjaxForm").on("submit", function(e){
        
        var $inputs = $('#callAjaxForm :input'), 
            values = {};
        $inputs.each(function() {
          values[this.name] = this.value;
        });
        
        $.ajax({
          type : "POST",
          url : "http://www.smspi.co.uk/login.app.php",
          data: values,
		  cache: false,
		  crossDomain: true,
		success: function(data, status){ 
		 var obj = (data[0]);
		 if (obj.error == true) {
		 $("#result").html(obj.message);
          $("input[type=text]").val("");
		   }
		   if (obj.error == false)
		   {
		   var myhash = (obj.message);
		   setCookie("hash",myhash,50);
		   window.location.replace("sendsms.html");
		   }
      }
	  
    });
   return false
  });
</script>

on ANY device it returns the json from the login.app.php but when you press back and then login again it does as it’s told and logs in.

can any one advise how to fix this bear in mind this will be a phonegap app so i know showing the sendsms.html page isnt a security risk.