1. Remove the AJAX call from the each loop and place it outside below he loop.
2. Create a new array above the loop.
var Customers = new Array();
3. Add the Customer Object to the Array.
Customer.Id = $(this).find("td:nth-child(2)").html();
Customer.Name = $(this).find("td:nth-child(3)").html();
Customer.Country = $(this).find("td:nth-child(4)").html();
Customers.push(Customer);
4. In the AJAX call use the following for data parameter
data: '{Customers: ' + JSON.stringify(Customers) + '}',
5. Finally in WebMethod change as follows
public static string SaveGridViewRowData(List<customers> Customers)
6. Now Loop and insert each Customer
foreach(customers Customer in Customers)
{
SqlCommand cmd1 = new SqlCommand("spinsertcustomer", conn);
cmd1.CommandType = CommandType.StoredProcedure;
cmd1.Parameters.AddWithValue("@id", Customer.Id);
cmd1.Parameters.AddWithValue("@name", Customer.Name);
cmd1.Parameters.AddWithValue("@country", Customer.Country);
conn.Open();
cmd1.ExecuteNonQuery();
conn.Close();
}