i use $.ajax() method for better event handling
client side js coding:
$.ajax({ url:"http://another.domain.com", dataType: 'jsonp', //stand for "json-padding", it is jsonp, not json //its "jsonpCallback", not "jsonCallback". the callback method name from JSON, will explain below jsonpCallback: 'jsonCallback', //set this to true to let the method know im loading data cross-domain crossDomain : true, //success handler success: function(data) { console.log("dosomthing") }, //error handler error: function() { console.log("error occured") } });
the json response, wrap the JSON with a function with the name which declared in jsonpCallback above:
jsonCallback( { "user":"littleshell", "gender":"male" } );