Just curious about ajax calls, so I have multiple ajax call function which calls different Url endpoints
but I find it sometimes one call fails and others get success.
Say I have these function and I know both calls works when I console log them, it returns me the value I needed however these calls will trigger once the page has loaded.
function xs () {
$.ajax({
url: 'api/endpoint1?loc="space"',
method: 'GET'
...
})
}
function xd () {
$.ajax({
url: 'api/endpoint2?name="x"',
method: 'GET'
...
})
}
How I trigger these functions and I call this file say calls.js
in my html and this will fire the ajax calls. But sometimes only 1 of them will get a success or sometimes both.
function init() {
xs();
xd();
}
init();
So just wondering if there's a better way of handling multiple AJAX
calls specially if you have more than 2.