title: AJAX request failing on mobile device
body: <p>If I try the following code in my browser it works but when I try it on my device (Samsung Galaxy S3) it won't complete the AJAX request.</p>
  
  <p>the AJAX request:</p>
  
  <pre><code>$.ajax({
      type: "POST",
      url: "http://somelink.nl/mobileajax/ajax.php",
      data: ({
          name: Username,
          pass: Pass,
          email: Email,
          firstname: FirstName,
          lastname: LastName
      }),
      cache: false,
      dataType: "text",
      success: alert('Succes')
  });
  </code></pre>
  
  <p>Hope you guys can help me!</p>
  
  <p>edit:</p>
  
  <p>Thanks for the help but it still won't work  found out that it's not the AJAX request going wrong but something else here is the full code:</p>
  
  <p>Javascript:</p>
  
  <pre><code>var app = {
      // Application Constructor
      initialize: function() {
          this.bindEvents();
      },
      // Bind Event Listeners
      //
      // Bind any events that are required on startup. Common events are:
      // 'load', 'deviceready', 'offline', and 'online'.
      bindEvents: function() {
          document.addEventListener('deviceready', this.onDeviceReady, false);
      },
      // deviceready Event Handler
      //
      // The scope of 'this' is the event. In order to call the 'receivedEvent'
      // function, we must explicity call 'app.receivedEvent(...);'
      onDeviceReady: function() {
          app.receivedEvent('deviceready');
      },
      // Update DOM on a Received Event
      receivedEvent: function(id) {
          var parentElement = document.getElementById(id);
          var listeningElement = parentElement.querySelector('.listening');
          var receivedElement = parentElement.querySelector('.received');
  
          listeningElement.setAttribute('style', 'display:none;');
          receivedElement.setAttribute('style', 'display:block;');
  
          console.log('Received Event: ' + id);
      }
  };
  
  function register()
      {
  
          var Username = $.trim($("#Username").val());
          var Pass = $.trim($("#Password").val());
          var Email = $.trim($("#Email").val());
          var FirstName = $.trim($("#FirstName").val());
          var LastName = $.trim($("#LastName").val());
  
          if((Username.length &gt; 0) &amp;&amp; (Pass.length &gt; 0) &amp;&amp; (Email.length &gt; 0) &amp;&amp; (FirstName.length &gt; 0) &amp;&amp; (LastName.length &gt; 0) )
              {
              $.ajax({
                  type: "POST",
                  url: "http://quincycollijn.nl/mobileajax/ajax.php",
                  data: ({name: Username, pass: Pass, email: Email, firstname: FirstName, lastname: LastName}),
                  dataType: "text",
                  success: onSucces,
                  error: function(jq,status,message) {
                      alert('A jQuery error has occurred. Status: ' + status + ' - Message: ' + message);
                  }
              });
          } else {
              alert('Niks ingevult');
          } 
  
  
          function onSuccess()
              {
                  alert('Result:');
              }
  }
  </code></pre>
  
  <p>HTML:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
    &lt;head&gt;
      &lt;title&gt;My Page&lt;/title&gt;
      &lt;meta name="viewport" content="width=device-width, initial-scale=1"&gt;
      &lt;link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css" /&gt;
      &lt;link rel="stylesheet" href="css/style.css" /&gt;
      &lt;script src="phonegap.js"&gt;&lt;/script&gt;
      &lt;script src="http://code.jquery.com/jquery-1.8.2.min.js"&gt;&lt;/script&gt;
      &lt;script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"&gt;&lt;/script&gt;
      &lt;script src="js/index.js"&gt;&lt;/script&gt;
    &lt;/head&gt;
    &lt;body onLoad="onBodyLoad()"&gt;
  
      &lt;div data-role="page" data-theme="a"&gt;
  
        &lt;div data-role="header"&gt;
          &lt;h1&gt;Chatup!&lt;/h1&gt;
        &lt;/div&gt;&lt;!-- /header --&gt;
  
        &lt;div data-role="content"&gt;
          &lt;div data-role="fieldcontain"&gt;
          &lt;img src="img/img_placeholder.png" class="placeholder" align="center" rel="Placeholder" &gt;  
            &lt;input class="login-input" data-mini="true" type="text" id="FirstName" name="first_name" placeholder="First Name" data-theme="b" &gt;
          &lt;/br&gt;&lt;/br&gt;&lt;/br&gt;
            &lt;input class="login-input" data-mini="true" type="text" id="LastName" name="last_name" placeholder="Last Name" data-theme="b" &gt;
          &lt;/br&gt;&lt;/br&gt;&lt;/br&gt;
            &lt;input type="text" data-mini="true" name="username" id="Username" placeholder="Username" data-theme="b" &gt;
            &lt;/br&gt;
            &lt;input type="text" data-mini="true" name="email" id="Email" placeholder="Email" data-theme="b" &gt;
            &lt;/br&gt;
            &lt;input type="password" data-mini="true" id="Password" name="password" placeholder="Password" data-theme="b" &gt;
            &lt;/br&gt;
  
            &lt;a href="#" class="register-button" data-role="button" data-theme="b"&gt;Register&lt;/a&gt;
          &lt;/div&gt;
        &lt;/div&gt;&lt;!-- /content --&gt;
      &lt;/div&gt;&lt;!-- /page --&gt;
  
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>