同时ajax请求django

时间:2013-01-21 22:53:17

标签: ajax django jquery

我在页面加载时触发了多个ajax调用。

来自request1我希望response1request2我期待response2。但我收到了response1request1 {/ 1}}的{​​{1}}。{/ p>

request2收到request2之后移动response1时,我按预期收到request2

如何安全地进行多次ajax调用?

一些代码:

//avoids problem
    this.update = function(){
        $.post('/ws/newsfeed/', {'action':'6'}).done( function(response){
            ...
            _this.get_alert_count()
        })
    }

    this.get_alert_count = function(){
        $.post('/ws/newsfeed/', {'action':'2'}).done(function(count) {
            ...
        })
    }

_this.update()

//causes problem
    this.update = function(){
        $.post('/ws/newsfeed/', {'action':'6'}).done( function(response){
             ...
        })
    }

    this.get_alert_count = function(){
        $.post('/ws/newsfeed/', {'action':'2'}).done(function(count) {
            ...
        })
    }

_this.update()
_this.get_alert_count()

0 个答案:

没有答案
相关问题