0

The code goes like this:

$.ajax({
    url: "http://server.com/rest",
    dataType: "jsonp",
    success:function(d, t, x) {
        console.log(d);
    },
    error:function(x, t, e) {
        console.log(x.responseText);
    }
});

Firebug shows that I am receiving a response but the code above only logs "undefined". Firebug also shows that the http status code is 200. Can anybody tell me how to retrieve the response?

OptimizedQuery
  • 1,262
  • 11
  • 21
ferd tomale
  • 845
  • 7
  • 20

1 Answers1

1

if you are using jsonp. your server should bind the response to a callback function. Example

server response

myFunction(someresponsehere)

client side

function myFunction(response)
{
  //you will get the response from server here "response"
  }
Anoop Joshi P
  • 25,373
  • 8
  • 32
  • 53
  • I know but in this case I don't control the server. The server only returns the data without the callback so the callback is never called. I can't use a non-jsonp call because I get an "No 'Access-Control-Allow-Origin' header is present on the requested resource" error. The only way I get data back is if I use jsonp. – ferd tomale Feb 27 '14 at 14:36
  • 1
    @ferdtomale than you are out of luck. – epascarello Feb 27 '14 at 14:40