jquery $.ajax call succeeds but returns nothing. (jsonp)

Posted by Shawn on Stack Overflow See other posts from Stack Overflow or by Shawn
Published on 2010-05-01T14:55:59Z Indexed on 2010/05/01 14:57 UTC
Read the original article Hit count: 150

Filed under:
|
|
$(document).ready(function() {
   $('#button').click(function() {
       try {
           var json = $.ajax({url : 'http://www.example.com/experimental/service.php', type : 'jsonp', success : function() {alert('success')}});
           alert(json);
        } catch(err) {
           alert(err.description)
        }
        var sjson = JSON.stringify(json);
       $('#display').html(sjson);
   })
}) 

After a button is pressed I get an alert message that says "success" and also one that says undefined, referring to the fact that nothing was returned from the ajax call. I checked the firebug 'net' tab and indeed i get a succesful response from the server of "jsonp1272724228884( {} );" Any ideas?

© Stack Overflow or respective owner

Related posts about AJAX

Related posts about jQuery