I am making Ajax call for getting data, I am getting 4 rows and those I am using to send an email via toSendEmail() method.. I need to use for loop for Ajax call because my ID is stored in Array (I am using Id to create URL of Ajax)..Here is code for that:
function getData() {
    console.log("Total Element:"+someIds.length); // 4 data
    for (var i=0; i< someIds.length;i++) {  
        $.ajax({
          url: '/SomeURL/' someIds[i];    
// Basic Ajax Coding (type, cache etc......)
            success: function (result1) {
                for(var i=0; i<result1.length; i++) {
                    // Storing data in Predefined arrays.. 
                }
            },
            error: function (error) {
                alert("Errror while.....");
            }
        }).done(function() {
            if(SomeData.length!=0) {
                toSendEmail();
            };
        });    
    }
}
My ajax call is working fine I am getting data as expected.. My problem is Email is getting sent 4 times. I want Email function should call only once. What I need to make changes in my code??
Thank You
 
     
    