 <p>You need to change window.location in a success callback since it may happen before the asynchronous POST request is finished.</p> <pre><code>$.ajax({ type: "POST", url: "/mobile.php", data: {values:"mobile"} success: function(){ window.location = "http://dekstopversionexample.lt"; } }); </code></pre>