jQuery成功后重新发送ajax调用

时间:2022-06-27 20:27:25

I want to be able to re-send an AJAX request (using jQuery) after is has been completed. This was my initial implementation

我希望能够在完成后重新发送一个AJAX请求(使用jQuery)。这是我最初的实施

$.ajaxSetup({  
  complete: function(xhr, status) {
    $.ajax(xhr)
  }
});

But it seems as though I haven't understood the documentation as this doesn't fire off a request to the same URL.

但似乎我没有理解文档,因为这不会触发对同一URL的请求。

Is there a way to complete this?

有没有办法完成这个?

(p.s. I understand that if the above example was to work, that it would be an infinite loop of the same ajax request, this has been reduced for example purposes only :) )

(p.s.我明白,如果上面的例子是有效的,它将是同一个ajax请求的无限循环,这只是为了示例目的而减少:))

1 个解决方案

#1


6  

Just do

$.ajax({
    url: "foo.cfc",
    success: function(){
        $.ajax(this);
    }
})

this is the settings passed in.

这是传入的设置。

The same works for completed, but your question title asks for success.

完成相同的工作,但你的问题标题要求成功。

#1


6  

Just do

$.ajax({
    url: "foo.cfc",
    success: function(){
        $.ajax(this);
    }
})

this is the settings passed in.

这是传入的设置。

The same works for completed, but your question title asks for success.

完成相同的工作,但你的问题标题要求成功。