无法让这个jquery getjson工作 [英] Can't get this jquery getjson to work

查看:73
本文介绍了无法让这个jquery getjson工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下内容:

 <   html  >  
< 正文 >
< 按钮 id = json > json < / button >
< script src = Scripts / jquery-2.0.3.js & gt; < / script >
< script 类型 = text / javascript >
$(document).ready(function(){
$('#json')。click(function() {
alert('json');
$ .getJSON(http://www.hpgloe.com/json/getrec/?lat=37.234&lon=-122.234,{},
函数(数据){
// alert(here);
alert(data);
})。fail(function(jqXHR,textStatus,errorThrown){alert(fail+ errorThrown);});
});
});
< / script >
< / body >
< / html >



但它只是给出了一条无用的消息:

失败错误

解决方案

(document).ready(function(){


('#json')。click (function(){
alert('json');


.getJSON(http://www.hpgloe.com/json/getrec/?lat=37.234& ; lon = -122.234,{},
函数(数据){
// alert(here);
alert(data);
})。fail( function(jqXHR,textStatus,errorThrown){alert(fail+ errorThrown);});
});
});
< / script >
< / body >
< / html >



但它只是给出了一条无用的消息:

失败错误


I have the following :

<html>
<body>
    <button id="json">json</button>
    <script src="Scripts/jquery-2.0.3.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $('#json').click(function () {
                alert('json');
                $.getJSON("http://www.hpgloe.com/json/getrec/?lat=37.234&lon=-122.234", {},
                function (data) {
                    //alert("here");
                    alert(data);
                }).fail(function (jqXHR, textStatus, errorThrown) { alert("fail " + errorThrown); });
            });
        });
    </script>
</body>
</html>


But it just gives a useless message :

fail error

解决方案

(document).ready(function () {


('#json').click(function () { alert('json');


.getJSON("http://www.hpgloe.com/json/getrec/?lat=37.234&lon=-122.234", {}, function (data) { //alert("here"); alert(data); }).fail(function (jqXHR, textStatus, errorThrown) { alert("fail " + errorThrown); }); }); }); </script> </body> </html>


But it just gives a useless message :

fail error


这篇关于无法让这个jquery getjson工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆