Javascript Jquery getJson不能与php json_encode一起使用

Javascript Jquery getJson不能与php json_encode一起使用,javascript,php,jquery,ember.js,Javascript,Php,Jquery,Ember.js,下面是php json_编码输出示例 {"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( "st

下面是php json_编码输出示例

{"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/Handlebar代码是

{{#if ustat.[0].user_status}}
do something
{{else}}
do something else
{{/if}}
但是,当我使用一些伪值时,user\u 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
不会返回调用中的数据,而是返回一个承诺。也许这样做会更好:

$.getJSON( "status.php").then(function(statusData){
   ...
   model: function(params) {
    return Em.RSVP.hash({
      uposts: tweets,
      ustat: [statusData]
    });
   }
   ...
});

getJSON
默认情况下执行异步(AJAX)请求,这不适合您的情况。您必须执行同步请求。这可以通过使用
async
选项的
$.ajax
实现