码迷,mamicode.com
首页 > 其他好文 > 详细

ajax 异步问题

时间:2014-09-05 14:18:51      阅读:170      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   io   for   数据   div   问题   cti   

PhysicianManagement.prototype.listPhysician = function() {
    alert(JSON.stringify(this.physicianList));  // {}
    alert(JSON.stringify(this.physicianRelList)); // {}
};

PhysicianManagement.prototype.initProviderInfo = function() {
    ajaxCallForEventWithJsonData(this,‘fetchProviderInformation‘,null, null, function (that,data) {
        that.physicianList = data;
    });
    ajaxCallForEventWithJsonData(this,‘fetchProviderRel‘,null, null, function (that,data) {
        that.physicianRelList = data;
    });
    ajaxCallForEventWithJsonData(this,‘fetchLoginUserInformation‘,null, null, this.initLoginUserInformation);
//由于异步,这里在数据还未请求结束就已经执行了
this.listPhysician(); };

 

解决办法

ajaxCallForEventWithJsonData(this,‘fetchProviderInformation‘,null, null, function (that,data) {
        that.physicianList = data;
        ajaxCallForEventWithJsonData(that,‘fetchProviderRel‘,null, null, function (innerThat,data) {
            innerThat.physicianRelList = data;
            innerThat.listPhysician();
            ajaxCallForEventWithJsonData(innerThat,‘fetchLoginUserInformation‘,null, null, innerThat.initLoginUserInformation);
        });
    });

ajax 异步问题

标签:style   blog   color   io   for   数据   div   问题   cti   

原文地址:http://www.cnblogs.com/shouwangzhe-/p/3957904.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!