I stuck on the following case:
I use PhantomJS to parse webpage. Webpage contains JSONP data which loads from other website. I'll try the following script:
var data = {};
function cb(d) {
data = d;
}
var aj = jQuery.ajax({
url: "http://url-to-jsonp&callback=cb",
dataType: 'jsonp',
jsonpCallback: 'cb',
jsonp: 'callback'
});
aj.done(function(res) { console.log(data); } );
I expext to see arguments of cb() function, but data array is empty. I think it happend because phantomjs close before data loaded. Any idea how to solve this?