title: Ajax request not working in eclipse when running on android emulator or phone
body: <p>Hello i am new to phonegap and jquery mobile and have a problem when trying to run my application via eclipse emulator and also on my htc phone. </p>
  
  <p>My code works perfectly when i run the application in firefox. The HTML calls a PHP script that runs on tomcat, the php script accesses the mysql and passes back jsonp data.</p>
  
  <p>Any help would be much appreciated. I have read other posts and have had not lock with my code.</p>
  
  <p>I have updated the android manifest with all the correct permissions as below:</p>
  
  <pre><code>&lt;uses-permission android:name="android.permission.VIBRATE" /&gt;
  &lt;uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /&gt;
  &lt;uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /&gt;
  &lt;uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" /&gt;
  &lt;uses-permission android:name="android.permission.READ_PHONE_STATE" /&gt;
  &lt;uses-permission android:name="android.permission.INTERNET" /&gt;
  &lt;uses-permission android:name="android.permission.RECEIVE_SMS" /&gt;
  &lt;uses-permission android:name="android.permission.RECORD_AUDIO" /&gt;
  &lt;uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" /&gt;
  &lt;uses-permission android:name="android.permission.READ_CONTACTS" /&gt;
  &lt;uses-permission android:name="android.permission.WRITE_CONTACTS" /&gt;
  &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /&gt;
  &lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /&gt; 
  &lt;uses-permission android:name="android.permission.GET_ACCOUNTS" /&gt;
  &lt;uses-permission android:name="android.permission.BROADCAST_STICKY" /&gt;
  </code></pre>
  
  <p>I have my html file below:</p>
  
  <pre><code>    &lt;!DOCTYPE HTML&gt;
  &lt;html&gt;
  &lt;head&gt;
  
  &lt;title&gt;Search by area&lt;/title&gt;
  &lt;meta name="viewport" content="width=device-width, initial-scale=1" /&gt;
  &lt;link rel="stylesheet" href="jquery.mobile.structure-1.2.0.min.css" /&gt;
  &lt;link rel="stylesheet" href="jquery.mobile-1.2.0.min.css" /&gt;
  &lt;script type="text/javascript" charset="utf-8" src="cordova-2.2.0.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript" src="jquery-1.8.3.min.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript" src="jquery.mobile-1.2.0.min.js"&gt; &lt;/script&gt;
  
  
  
  
  &lt;/head&gt;
  &lt;body&gt; 
  
      &lt;div id="areas" data-role="page" data-add-back-btn="true"&gt;
      &lt;script type="text/javascript"&gt;
  
  
       // alert dismissed
       function alertMessageDimissed()
       {
          // do something 
       }
  
       $("#areas").on('pageshow', function() {
                  // get the areas from the database 
          $.ajax({
              type:'GET',
              url:'http://localhost/getData.php',
              dataType:'jsonp',
              jsonp: 'jsoncallback',
              timeout: 5000,
              success: function(data, status)
              { 
                $.each(data, function(i,item){
                 var addToSession = 'sessionStorage.areaID=' + item.area_id;
                  $('#list').append("&lt;li&gt;&lt;a href='../www/choose_restaurant.html' onclick=" + addToSession + " data-transition='slidedown'&gt;" + item.area_name + 
                  "&lt;span class='ui-li-count'&gt;" + item.deal_count + "&lt;/span&gt;" +
                  "&lt;/a&gt;&lt;/li&gt;");
                  $("#list").listview("refresh");
  
  
                  });
  
  
              },
               error: function(data)
               {
                    // there was no connection to the internet 
                    navigator.notification.alert(
                      'No intenet connection', // message
                       alertMessageDimissed, // callback
                       'Information - Error', // title
                       'Done'                 // buttonName
                      );  
  
              }
          });
          return false;       
      });
      &lt;/script&gt;
  
          &lt;div data-role="header"&gt;
  
              &lt;h1&gt; Bucuresti deals&lt;/h1&gt;
  
          &lt;/div&gt;
  
          &lt;div data-role="content"&gt;
  
              &lt;div class="choice_list"&gt;
  
                  &lt;h1&gt; In which area do you want to eat? &lt;/h1&gt;
  
  
                  &lt;ul id="list" data-role="listview" data-inset="true" data-filter="true" &gt;
                  &lt;/ul&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>My working php script is below:</p>
  
  <pre><code>&lt;?php
  header('Content-type: application/json');
  
  $server = "127.0.0.1:3306";
  $username = "root";
  $password = "";
  $database = "deals";
  
  $con = mysql_connect($server, $username, $password) or die ("Could not connect: " . mysql_error());
  mysql_select_db($database, $con);
  
  
  $sql = "SELECT a.area_id, a.name AS area_name, a.sector AS area_sector,
      (SELECT Count(*) FROM deals.main_deals b WHERE b.areaID = a.area_id) as deal_count
       FROM deals.areas a";
  
             $result = mysql_query($sql) or die ("Query error: " . mysql_error());
  
  $records = array();
  
  while($row = mysql_fetch_assoc($result)) {
      $records[] = $row;
  }
  
  mysql_close($con);
  
  echo $_GET['jsoncallback'].'(' . json_encode($records) . ');';
  ?&gt;
  </code></pre>