0

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?

1 Answer 1

2

It is not a valid JSON.

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

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

Sign up to request clarification or add additional context in comments.

2 Comments

Updated url to include ?callback=? Also, changed my demo service to valid json- imgsvc.heroku.com/images still have same error though
It was my "service" - i added support for the callback, and it works now. thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.