Multiple Ajax Requests

0

I just did a routine to retrieve information from Google Maps, using its API. But I needed to use CURL in PHP to make the request, why when I go directly to AJAX in JS, it accuses me of the error in Allow Origins Access Control and I never managed to solve it.

Then I left for CURL. But whatever happens, there are several requisitions. I'm getting the distance from one address to another via the Google API.

And there are several records on the screen and precise the distance of each one in real time, since I get the user's current location.

So there can be more than 10 requests.

Is there any better way to do this?

To understand, I'll post the code:

$.each(allEnderecos, function(i, v){
    var enderecoLocal = $(v).val();
    $.ajax({
        url: urlBase + '/select-endereco-local',
        data: { ea: enderecoAtual, el: enderecoLocal },
        dataType: "json",
        type: "POST",
        success: function(data){
            $(v).closest('div.info-dealer').find('span.geoval').html(data);
        }
    });
});

See each . It is an unknown quantity of addresses that may have on screen. It depends on the user's query.

1 - Is this dangerous?

2 - Does it interfere with site performance?

I thought without taking the information all at once and returning everything at once. But in PHP it has a CURL for another LINK, so I think it works the same.

    
asked by anonymous 04.04.2016 / 13:50

0 answers