title: How to avoid a changePage immediately after ajax post with javascript
body: <p>Help!</p>
  
  <p>I am using jquery mobile to submit a JSON string to my rails app via an ajax post. The string contains some data that I send via the following ajax call in a JS file:</p>
  
  <pre><code>$.ajax({
  url: "http://" + MyURL + ".json",
  type: "POST",
  data: JSON.stringify(this.form),
  dataType: "json",
  contentType: "application/json",
  success: onSaveSuccess,
  error: onFailure,
  complete: onComplete
  });
  </code></pre>
  
  <p>This code works, but as soon as I press the button to submit the form, it changes the page to my home page (NOT EVEN THE PREVIOUS PAGE). I want to set this post up so that it doesn't change pages until I tell it to (in either the success or complete functions). I don't want the user to be thrown around different pages after submitting the post. Instead, I want to show my upload spinner until it is done, and then I will redirect them to a specific page. </p>
  
  <p>Does anyone know how to do this?</p>
  
  <p>My login screen uses a (nearly) identical ajax script, and it does exactly what I want. I am assuming that is because there is no page to go "back" to. I don't understand this behavior, so if anyone does, your advice would be appreciated.</p>