Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/476.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/89.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
jQuery中的JSONP Javascript是如何更改的?_Javascript_Jquery - Fatal编程技术网

jQuery中的JSONP Javascript是如何更改的?

jQuery中的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

我想将JSONP纯Javascript代码转换为jQuery

  • 下面的代码如何更改jQuery

  • 我必须使用整个jQuery库还是只能使用一些模块

    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是开源的,所以理论上可以只包含一个子集,但库不是模块化的。我不推荐它。

    您好,谢谢您的回答,但我如何将其放入函数中呢?