Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/78.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/4/json/15.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 json谷歌ws api_Jquery_Json_Api - Fatal编程技术网

jquery json谷歌ws api

jquery json谷歌ws api,jquery,json,api,Jquery,Json,Api,你好 我正在尝试从本地主机获取google json 我得到:行:4984错误:访问被拒绝。从jquery 缺少什么 这就是密码 <script type="text/javascript" charset="utf-8"> $(document).ready(function () { var _url = 'https://ajax.googleapis.com/ajax/services/search/images?v=1.0&q=fuzzy

你好 我正在尝试从本地主机获取google json

我得到:行:4984错误:访问被拒绝。从jquery 缺少什么

这就是密码

<script type="text/javascript" charset="utf-8">
    $(document).ready(function () {

        var _url = 'https://ajax.googleapis.com/ajax/services/search/images?v=1.0&q=fuzzy%20monkey';
        _url = 'http://code.google.com/ajax/services/search/images?v=1.0&q=fuzzy%20monkey';
        var _serverParam = "";

        var aa = $.getJSON(_url, _serverParam, theCallBack);
        //        alert(aa);
        //        function theCallBack(theData, theStatus) {
        //            alert(theData); alert(theStatus);
        //        }

    });
    function theCallBack(theData, theStatus) {
        alert(theData); alert(theStatus);
    }
</script>

$(文档).ready(函数(){
var\u url=https://ajax.googleapis.com/ajax/services/search/images?v=1.0&q=fuzzy%20monkey';
_url='1〕http://code.google.com/ajax/services/search/images?v=1.0&q=fuzzy%20monkey';
var_serverParam=“”;
var aa=$.getJSON(_url,_serverParam,theCallBack);
//警报(aa);
//回调函数(数据、状态){
//警报(数据);警报(状态);
//        }
});
回调函数(数据、状态){
警报(数据);警报(状态);
}
我想你设置了两次url,然后打电话给我 _url='1〕http://code.google.com/ajax/services/search/images?v=1.0&q=fuzzy%20monkey';

哪个失败了:

如果您将第二个url设置为其他url,并调用第一个已建立的url,您会发现它是有效的。
-检索图像文件。

是的,第二个url似乎已断开-它返回404错误。但是,您需要将“&callback=?”添加到URL的末尾,以避免得到XMLHttpRequest错误(源代码)http://... 访问控制(允许原点)不允许

以下是有效的代码:

$(document).ready(function () {
    var _url = 'https://ajax.googleapis.com/ajax/services/search/images?v=1.0&q=fuzzy%20monkey&callback=?';
    //_url = 'http://code.google.com/ajax/services/search/images?v=1.0&q=fuzzy%20monkey&callback=?';

    $.getJSON(_url, function (data) {
        alert(data);
    });
});

您使用的是哪个版本的jQuery?我知道。。在naivete上使用url是可以的,但是。。。从jqueryfunc我得到了这个错误
$(document).ready(function () {
    var _url = 'https://ajax.googleapis.com/ajax/services/search/images?v=1.0&q=fuzzy%20monkey&callback=?';
    //_url = 'http://code.google.com/ajax/services/search/images?v=1.0&q=fuzzy%20monkey&callback=?';

    $.getJSON(_url, function (data) {
        alert(data);
    });
});