首页 > 其他 > 详细

ajax 异步问题

时间:2014-09-05 14:18:51      阅读:270      评论:0      收藏:0      [点我收藏+]
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 异步问题

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!