title: Phonegap - Fetch External Website Data?
body: <p>I am creating an app using Phonegap (Android) and Javascript / JQuery. I have a Javascript page where I want to read in the text from an external web page. For some reason I am not able to get this to work. </p>
  
  <p>My Javascript page within my app</p>
  
  <pre><code>$.mobile.allowCrossDomainPages = true;
  
  $(document).ready(function () {
  
  $.ajax({
          url: 'myexternalserver.com/test.php',
          dataType: 'jsonp',
          jsonp: 'jsoncallback',
          timeout: 5000,
          success: function(data, status){
  
              alert("connected");
  
          },
          error: function(){
  
              alert("jsonp error");
          }
          });
  });
  </code></pre>
  
  <p>My PHP page on external server</p>
  
  <pre><code>// $out is an array of text
  
  echo $_GET['jsoncallback'] . '(' . json_encode($out) . ');';
  </code></pre>
  
  <p>I modified my Cordova.xml file to include</p>
  
  <pre><code>&lt;access origin="http://myexternalserver.com" subdomains="true"/&gt;
  </code></pre>
  
  <p>Am I missing any other steps? I always get a connection error. </p>
  
  <p>Thanks. </p>
  
  <p>EDIT:</p>
  
  <p>I have modified my javascript page to the following</p>
  
  <pre><code>$.getJSON("http://myexternalserver.com/test.php?var=test&amp;callback=?", {
  success:function(data){
              alert("Working");
  
              var ot = jQuery.parseJSON( data );
  
              alert(ot);
  
  }, error: function() { 
      alert("Error"); 
  }
  });
  </code></pre>
  
  <p>I now get the "working" alert but the data reads as null. </p>