jsonp: function(url, data, callback){ if( wfQuery.isFunction(data) ){ callback = data; data = {}; } var cbk_name = "wfQuery_" + +new Date; data.__t = +new Date; data.callback = cbk_name; var _sc = doc.createElement('script'); _sc.src = url + '?' + wfQuery.param( data ); var sc = wfQuery(_sc); wfQuery('body').append( sc ); window[cbk_name] = callback || function(){}; sc.on('load',function(){ delete window[cbk_name]; sc.remove(); }); }
这是wfquery中关于jsonp的简单实现,类似jquery。