Dear All I would like to ask I have a scenior where I need to call a service using ajax which will open my windows service interface I have done it using javascript ajax but the issue is
$.Ajax({
uri:my service URL ;
type:POST
})
my ajax code works fine it call the serive and open up the windows service interface as well , The issue is I would like to post this data as well but for posting data I need to provide URL (specifiying the controller and action name ) but how I will do that as I am already using URI attribute to call windows service so how to call another URL to post this service data in controller means two URL

Tahir AnsariRank #366 · 6.8K reputationPosted Jul 17, 2024, 9:15 AM EDT
Hi,
AJAX calls can only target one URL per request. If you need to interact with multiple URLs or endpoints in a single operation, you typically need to structure your application to handle this interaction in a different manner.
// First AJAX call to call the Windows service $.ajax({ url: 'http://windows-service-url', type: 'POST', success: function(response) { console.log('Windows service call succeeded'); // Assuming you need to use data from this call in the next AJAX call var responseData = response.data; // Second AJAX call to post data to another URL $.ajax({ url: 'http://api-endpoint-url', type: 'POST', data: { key: 'value', }, success: function(response) { console.log('Data posted successfully'); }, error: function(xhr, status, error) { console.error('Error posting data:', error); } }); }, error: function(xhr, status, error) { console.error('Error calling Windows service:', error); } });Malik Danish Habib168 reputationPosted Jul 17, 2024, 11:33 AM EDT
Dear Tahir do you think we can do that you have put to ajax calls in one function of JS ?
Asma KhalidRank #160 · 14.7K reputationPosted Jul 17, 2024, 11:07 PM EDT
use another ajax call within your current ajax call's success scenario.