Jquery getJson无法使用php json_encode
Jquery getJson not working with php json_encode
以下是示例php json_encode输出
{"user_id":34543456532,"user_status":true,"name":"ABC","propic":"http:'/'/pbs.twimg.com'/profile_images'/....."}
我正在使用余烬,所以路线是
model: function(params) {
return Em.RSVP.hash({
uposts: tweets,
ustat: [$.getJSON( "status.php")]
});
}
处理这个问题的HTML/Handerbars代码是
{{#if ustat.[0].user_status}}
do something
{{else}}
do something else
{{/if}}
然而,当我使用一些伪值(如)时,user_status总是返回false
model: function(params) {
return Em.RSVP.hash({
uposts: tweets,
ustat: [{"user_id":34543456532,"user_status":true,"name":"ABC","propic":"http:'/'/pbs.twimg.com'/profile_images'/....."}]
});
}
它运行良好,错误在哪里?我该如何修复它?感谢
$.getJSON
不返回调用中的数据,而是返回promise。也许这样的东西会更好用:
$.getJSON( "status.php").then(function(statusData){
...
model: function(params) {
return Em.RSVP.hash({
uposts: tweets,
ustat: [statusData]
});
}
...
});
相关文章:
- 如何使用jquery返回php-json数组对象
- 无法读取js中的php JSON编码数据
- PHP JSON编码输出与Javascript Ajax不兼容
- 如何在php JSON编码结果中包含谷歌分析
- jQuery在没有数据库的情况下从php-json自动完成
- AJAX PHP JSON编码未返回所有结果
- 将编码的 PHP JSON 传递给 JavaScript
- PHP json 格式编码
- 如何创建正确的 PHP JSON 响应
- 如何从 PHP JSON 编码制作这个 JavaScript 对象
- 钛 - PHP + JSON 解析错误
- php json - 仅从数组中获取第一个元素
- 创建一个 PHP json 提要并成功将其链接到 javascript
- DatePicker php json 不起作用
- 在 Javascript 中解析 PHP/JSON 数据
- 将 php JSON 对象转换为数组
- PHP JSON 不能回显值,总是返回一个数组
- 为什么 php json 响应不会将数据数组发送回 ajax jquery 请求
- PHP JSON Returns u0000
- 在 JavaScript 中使用 php json 结果