title: Ajax/PHP login form - developing an android app(Jquery.mobile) using phonegap
body: <p>My Index.html file code as follows:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt; 
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta charset="utf-8"&gt;
  &lt;title&gt;Mindcorpus - Placement&lt;/title&gt;
  &lt;link href="style.css" rel="stylesheet" type="text/css"/&gt;
  &lt;script src="jquery.js" type="text/javascript"&gt;&lt;/script&gt;
  &lt;script src="jquery-mobile.js" type="text/javascript"&gt;&lt;/script&gt;
  &lt;script src="/cordova.js" type="text/javascript"&gt;&lt;/script&gt;
  &lt;script&gt;
  $(function()
  {
  $('#frm').submit(function()
  {
      var username = $('#textinput').val();
      var username = $.trim(username);
      var password = $('#passwordinput').val();
      var password = $.trim(password);
      if(username=='')
      {
          $('.error').html('Please enter username');
          return false;
      }
      else if(password =='')
      {
          $('.error').html('Please enter password');
          return false;
      }
      else
      {
          var user = $('[name=username]').val();
          var pass = $('[name=password]').val();
          $.ajax({
          type: 'POST',
          url: 'http://localhost/mc-new/admin/mobile1/process.php',
          data: { username: user, password: pass},       
          success: function(data){
              alert(data.success);
          },
          error: function(){
              alert('error!');
          }
      });
   return false;
      }
  });
  });
  &lt;/script&gt;
  &lt;/head&gt; 
  &lt;body&gt; 
  &lt;div data-role="page" id="page"&gt;
  &lt;div data-role="header"&gt;
      &lt;h1&gt;&lt;img src="images/logo.png" /&gt;&lt;/h1&gt;
  &lt;/div&gt;
  &lt;div data-role="content"&gt;
      &lt;div class="error"&gt;&lt;/div&gt;
      &lt;form action="" method="post" id="frm"&gt;
        &lt;div data-role="fieldcontain"&gt;
          &lt;input type="text" name="username" placeholder="Username" id="textinput" value=""  /&gt;
      &lt;/div&gt;
        &lt;div data-role="fieldcontain"&gt;
          &lt;input type="password" name="password" placeholder="******" id="passwordinput" value=""       /&gt;
      &lt;/div&gt;
        &lt;button data-icon="arrow-r" type="submit"&gt;Submit&lt;/button&gt;
      &lt;/form&gt;
  &lt;/div&gt;
  &lt;div data-role="footer"&gt;
      &lt;h4 style="font-weight:normal"&gt;Powered By: Mind Processors&lt;/h4&gt;
  &lt;/div&gt;
   &lt;/div&gt;
   &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>And my process.php file is:</p>
  
  <pre><code>&lt;?php
  if(isset($_POST['username']) || isset($_POST['password'])) 
  {
      $data['success'] = 'Done';
      echo json_encode($data);
  }
  ?&gt;
  </code></pre>
  
  <p>This functions is properly working when I use localhost on my browser. BUt when I use Dreamweaver and build &amp; Emulate this site. It always alert error. The Ajax is not functioning in emulator. The request is not passed to process file. Please help me &amp; sort out this problem.</p>