jQuery中的JSONP Javascript是如何更改的?
我想将JSONP纯Javascript代码转换为jQueryjQuery中的JSONP Javascript是如何更改的?,javascript,jquery,Javascript,Jquery,我想将JSONP纯Javascript代码转换为jQuery 下面的代码如何更改jQuery 我必须使用整个jQuery库还是只能使用一些模块 function requestServerCall(url) { var head = document.head; var script = document.createElement("script"); script.setAttribute("src", url); head.appendChild(scrip
function requestServerCall(url) {
var head = document.head;
var script = document.createElement("script");
script.setAttribute("src", url);
head.appendChild(script);
head.removeChild(script);
}
function Response(data) {
alert(data.token);
}
function group() {
requestServerCall("http://domain.com?callback=Response&y=" + y + "");
}
group();
嗯,有很多选择,但是:
$.ajax("http://domain.com?y=" + y, {
dataType: "jsonp",
success: function(data) {
alert(data.token);
}
});
由于jQuery是开源的,所以理论上可以只包含一个子集,但库不是模块化的。我不推荐它。您好,谢谢您的回答,但我如何将其放入函数中呢?