JSONP callback method not defined

I am trying to run jsonp callback using jquery inside a greasemonkey script. Here is my jquery:

$.ajax({
    url: "http://mydomain.com/MyWebService?callback=?",
    data: { authkey: "temphash" },
    type: "get",
    dataType: "json",
    cache: false,
    success: function(data) {
        console.log(data);
    }
});

in my webservice (asp.net) I am returning a response with a content type application/javascript. The answer that the server actually sends is:

jsonp1276109314602({"message":"I'm getting tired of this not working"})

The method name is jsonp1276109314602randomly generated by jquery and I grab it withRequest.QueryString["callback"]

However, my success function is never called, and the firebug console gives me an error message jsonp1276109314602 is not defined.

What am I doing wrong?

greasemonkey script Craigslist. , , , - , jquery, , , . , script firebug Craigslist, , greasemonkey script.

+5
3

, (), greasemonkey script.

: jQuery.getJSON greasemonkey script.

- JSONP script:

// @require http://courses.ischool.berkeley.edu/i290-4/f09/resources/gm_jq_xhr.js

, , , , , script.

+2

:

$.ajax({
    url: "http://mydomain.com/MyWebService",
    data: { authkey: "temphash" },
    type: "get",
    dataType: "jsonp",
    cache: false,
    success: function(data) {
        console.log(data);
    }
});

docs:

"jsonp": JSON JSONP. "? Callback =?" URL-, .

jQuery, , , jsonp dataType.

+3

, "jsonpCallbackString" "success".

http://api.jquery.com/jQuery.ajax/

+1

All Articles