0

I'm trying to parse a Json, it is here. When I launch the browser, after 2 seconds, there is an error:

Resource interpreted as Script but transferred with MIME type text/html:

Why? What is this error?

JS

function example()
{   
  alert("hello nice");
  var URL = "http://sath3g.altervista.org/index.php";
  $.ajax(URL, {
        crossDomain: true,
        dataType: "jsonP",
        type: 'GET',
        success: function (data, text, xhqr) {
            $.each(data, function(i, item) {
                alert(item);
                });
               },
        });
 }

HTML

<!DOCTYPE html>
<html>
<head>
  <title>Parse Json</title>
  <script src="parse.js"></script>
  <script type="text/javascript" src="jquery-2.1.0.min.js"></script>
</head>
<body onload="example()">
   <header id="title">
        Parsami tutta  
   </header>
   <form>

    </form>
</body>
</html>
chris97ong
  • 6,870
  • 7
  • 32
  • 52
Loris812
  • 15
  • 3
  • Are you sure the response is jsonp , go to following link to see more about jsonp http://stackoverflow.com/questions/2067472/what-is-jsonp-all-about . – Syed Shoaib Abidi Apr 09 '14 at 09:36

2 Answers2

0

You aren't making an error (unless you are also the author of the webservice). sath3g.altervista.org is sending the wrong Content-Type HTTP response header for its JSON and JSONP documents.

It looks like it is written by someone who knows some PHP but not enough about HTTP. By default PHP will claim that it is outputting HTML and you need to explicitly override that if you are sending JSON (header("Content-Type: application/json")) or JSONP (header("Content-Type: application/javascript")).

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
0

You need to modify you ajax call property

dataType: 'jsonp',

Here jsonp is in small-case

jsonp: 'jsonp',

Also try after adding above property

Chirag Vidani
  • 2,519
  • 18
  • 26