title: Parsing JSON data in PHP file using Javascript
body: <p>I have seen some other posts in Stackoverflow which were related. Tried that code but it did not work out for me. </p>
  
  <p>actually i have a database with 2 images of an actress in my MYSQL database. I am generating JSON data using PHP and it works fine. </p>
  
  <p><a href="http://chipap.com/apps/nazriya_nazim/test1.php" rel="nofollow">Link for JSON data</a></p>
  
  <p>I am trying to parse it with Javascript as shown in this fiddle</p>
  
  <p><a href="http://jsfiddle.net/rGKGV/" rel="nofollow">Direct Parsing Fiddle Link</a></p>
  
  <pre><code>var json = [{
      "id": "1",
      "url": "http:\/\/i.imgur.com\/J8yqh3y.jpg"
  }, {
      "id": "2",
      "url": "http:\/\/i.imgur.com\/WNx9i2c.jpg"
  }];
  var nazriya = json;
  $.each(nazriya, function (index, nazriya_nazim) {
      $('#url-list').append('&lt;li&gt;' +
          '&lt;h4&gt;' + nazriya_nazim.url + '&lt;/h4&gt;' +
          '&lt;/li&gt;');
  });
  </code></pre>
  
  <p>and it works fine. </p>
  
  <p>But if i try to parse it from my PHP file located in my domain. It does not display anything. It shows blank page. </p>
  
  <p><a href="http://jsfiddle.net/dj8LR/" rel="nofollow">FIDDLE Link : Parsing JSON data on PHP File</a></p>
  
  <pre><code>type: "POST",
  dataType: 'json',
  url: "http://chipap.com/apps/nazriya_nazim/test1.php",
  success: function (data) {
      alert("1");
      //var obj = jQuery.parseJSON(idata);
      var json = JSON.parse(data);
      $.each(json, function (index, nazriya) {
          $('#url-list').append('&lt;li&gt;' +
              '&lt;h4&gt;' + nazriya.url + '&lt;/h4&gt;' +
              '&lt;/li&gt;');
      });
  }
  </code></pre>
  
  <p>I did not write all these code on my own. Browsed Stack and found solutions. But stuck up at the last step (parsing from a PHP file located in my server).</p>
  
  <p>As said by @DaGLiMiOuX tried it in a separate HTML document.</p>
  
  <pre><code>&lt;head&gt;
  
  &lt;script src="http://code.jquery.com/jquery-1.9.1.min.js"&gt;&lt;/script&gt;
  &lt;script src="http://code.jquery.com/jquery-migrate-1.2.1.min.js"&gt;&lt;/script&gt;
  &lt;script&gt;
  $.ajax({
      type: "POST",
      dataType: 'jsonp',
      url: "http://chipap.com/apps/nazriya_nazim/test1.php",
      success: function (data) {
          alert("1");
          var json = data;
          $.each(data, function (index, nazriya) {
              $('#url-list').append('&lt;li&gt;' +
                  '&lt;h4&gt;' + nazriya.url + '&lt;/h4&gt;' +
                  '&lt;/li&gt;');
          });
      },
      error: function(jqXHR, status, errorText) {
          alert('Status code: ' + jqXHR.status +
                '\nStatus text: ' + status + '\nError thrown: ' + errorText);
      }
  });
  
  &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;ul id="url-list"&gt;&lt;/ul&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p>Now also it shows the same error. </p>