Alex
Alex

Reputation: 38499

jQuery GetJSON / ajax returning error

I'm currently testing out retrieving json from jquery.

The "service" url is:
http://imgsvc.heroku.com/images

In case that doesn't work, the contents of the response are:

[
"12345"
"39879827"
"9762974"
]

I have created a simple test.htm page (located on my local machine)

This is the jquery I'm using:

  $.ajax("http://imgsvc.heroku.com/images/?callback=?", {
    crossDomain: true,
    dataType: "jsonp",

    error: function() { alert("error"); },

    success: function (data, text, xhqr) {
      $.each(data, function (i, item) {
        alert(item);
      });
    }
  });

In chrome, all I get is "Resource interpreted as Script but transferred with MIME type application/json"

I also get an alert pop up "error" - as I told it to do this when there is an error.

Any idea what I'm doing wrong?

Upvotes: 0

Views: 345

Answers (1)

genesis
genesis

Reputation: 50966

It is not a valid JSON.

[
"12345",
"39879827",
"9762974"
]

is correct. Also, you need callback() function from jsonp.

Upvotes: 2

Related Questions