开发者

How to run an ajaxcall after another completes?

开发者 https://www.devze.com 2023-04-10 01:59 出处:网络
Just wondering, in my opinion the code below is able to run a second ajaxfunction when the first one completes.

Just wondering, in my opinion the code below is able to run a second ajaxfunction when the first one completes.

if(xmlHttp) // xmlHttp is an XMLHttpRequest开发者_JAVA百科 object
  {
    xmlHttp.onreadystatechange = function()
    {
      if(xmlHttp.readyState == 4 && xmlHttp.status == 200)
      {
         // second call can be made here because a first one is ready?
      }
   }

Am I correct on this? Or do I misunderstand the thing I want to achieve?


yes you can do that, but it might be better to call a function that does your second request flow.

0

精彩评论

暂无评论...
验证码 换一张
取 消