title: Ajax request to localhost php using jsonp not working
body: <p>Hi am using a Jquery to call a php script. The php script is located at <code>http://localhost:8080/getData.php</code> and it accesses a MySql database.</p>
  
  <p>I am using a tomcat server setup on my pc with the server address of localhost:8080</p>
  
  <p>I have looked at the ajax response data.status and it is 0</p>
  
  <p>I have read about cross domain requests and know that this should not be a problem if i am using JSONp. </p>
  
  <p>Any help would be much appreciated.</p>
  
  <p><strong>The jquery part inside of my HTML i use to call an ajax function is below:</strong></p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  $(document).ready(function() {
     $.ajax({
         type:'GET',
         url:'http://localhost/getData.php',
         datatype:'jsonp',
         timeout: 5000,
         success: function(data){
             //data loaded
             alert('loaded');
  
         },
         error: function(data){
             // error on loading data
             alert('error');        
         }
      });
  });
  &lt;/script&gt;
  </code></pre>
  
  <p><strong>The actual getData.php code is below:</strong></p>
  
  <pre><code>&lt;?php
  header('Content-type: application/json');
  
  $server = "127.0.0.1";
  $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 area_id, name AS area_name, sector AS area_sector FROM deals.areas ORDER BY name";
  $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>