Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple url in same ajax call?is this possible?

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',
     url: '../services/form_data.php', //can I send data to multiple url with same ajax call.
     data: {
         answer_service: answer,
         expertise_service: expertise,
         email_service: email,
     },
     success: function (data) {
         $(".error_msg").text(data);
     }
 });
like image 339
HIRA THAKUR Avatar asked Aug 07 '13 07:08

HIRA THAKUR


1 Answers

You can't use the same code for 1 request from many pages.

BUT you can send 2 requests. its can be done by copy paste your ajax code or by build a function that gets URL and send request with this URL

function sendMyAjax(URL_address){
    $.ajax({
         type: 'POST',
         url: URL_address,
         data: {
             answer_service: answer,
             expertise_service: expertise,
             email_service: email,
         },
         success: function (data) {
             $(".error_msg").text(data);
         }
     });
};
like image 177
Or Duan Avatar answered Oct 20 '22 06:10

Or Duan