Hi All -

I'm fairly new to jQuery, and totally new to jsonp.  I would like to
see an example of an $.ajax call using jsonp - as of right now, this
is what I have tried (based on examples found via Google searches and
the text description on the $.ajax page), but nothing fires any of the
callbacks:

One:
function test(){
        var jsonObj ={
                dataOne: "foo",
                dataTwo: "foo",
        };

        $.ajax({
                type:          "GET",
                url:             "https:myurl.com",
                dataType:   "jsonp",
                data:          jsonObj,
                error:          function(){alert('bad');},
                success:    function(){alert('good');},
                complete:   function(){alert('foo');}
        });
}

Two:
function test(){
        var jsonObj ={
                dataOne: "foo",
                dataTwo: "foo",
        };

        $.ajax({
                type:          "GET",
                url:             "https:myurl.com",
                dataType:   "jsonp",
                jsonp:        "testCallback",
                data:          jsonObj
        });
}

function testCallback(){alert('foo');}

Three:
function test(){
        var jsonObj ={
                dataOne: "foo",
                dataTwo: "foo",
        };

        $.ajax({
                type:          "GET",
                url:             "https:myurl.com?testCallback=?",
                dataType:   "jsonp",
                data:          jsonObj
        });
}

function testCallback(){alert('foo');}

Four:
function test(){
        var jsonObj ={
                dataOne: "foo",
                dataTwo: "foo",
        };

        $.ajax({
                type:          "GET",
                url:             "https:myurl.com?callback=testCallback",
                dataType:   "jsonp",
                data:          jsonObj
        });
}

function testCallback(){alert('foo');}

Any help would be much appreciated!  Thanks!!!

Reply via email to