getJSON不返回任何东西 [英] getJSON not returning anything

查看:133
本文介绍了getJSON不返回任何东西的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面的JSON函数不返回任何内容...

The JSON function below is not returning anything...

$.getJSON(formUrl, function(data) {
                alert(data)
              $('.response').html('<p>' + data.title + '</p>'
                + '<p>' + data.description + '</p>');
            });

formUrl是正确的,并且以

the formUrl is correct and returning data in the form of

{"title":"Smashing Magazine","description":"Smashing Magazine is focused on design and web-development. We deliver useful information, latest trends and techniques, useful ideas, innovative approaches and tools."}

有人可以指出我做错了什么吗?我正在提醒数据及其空白...

Can someone point out what I'm doing wrong? I'm alerting the data and its empty as well...

谢谢!

推荐答案

您是否使用跨域URL调用$.getJSON(即从本地主机到其他地方)?除非您使用JSONP数据类型,否则将无法正常工作.

Are you calling $.getJSON with a cross-domain URL (ie. from localhost to somewhere else)? That won't work unless you use the JSONP dataType.

这篇关于getJSON不返回任何东西的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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