Multiple url in same ajax call?is this possible?

后端 未结 4 1045
忘了有多久
忘了有多久 2020-12-01 11:16

Can I send my data to multiple pages using ajax call? I dont want to use another ajax call for this.

Sample code:

 $.ajax({
     type: \'POST\',
             


        
4条回答
  •  南笙
    南笙 (楼主)
    2020-12-01 11:49

    Using '$.when' could be an alternative as well. I have used it in one of my project.

    Reading jQuery API instructions:

    Execute the function myFunc when both ajax requests are successful, or myFailure if either one has an error.

    $.when( $.ajax( "/page1.php" ), $.ajax( "/page2.php" ) )
      .then( myFunc, myFailure );
    

提交回复
热议问题