Hii I had done below method in ajax , i have to insert monday,tuesday,wednesday like days but it inserts in non order sometimes it inserts monday first and sometimes it inserts thursday first please help me. i reffered many sites, All told to implement sleep is there any other way to do Thanks in advance
for (i = 1; i <= x; i++) {
AvailDay = $.trim($('#day_' + i).text()).replace(/[\s\n\r]+/g, ' ');
alert(AvailDay);
AMFrom = $('#amfrom_' + i).val();
AMTo = $('#amto_' + i).val();
PMFrom = $('#pmfrom_' + i).val();
PMTo = $('#pmto_' + i).val();
$.ajax({
type: "POST",
url: "ProviderSignup.aspx/AddAvailibility",
data: "{'ProviderId':'" + parseInt(ProviderId) + "','AvailDay':'" + AvailDay + "','AMFrom':'" + AMFrom + "','AMTo':'" + AMTo + "','PMFrom':'" + PMFrom + "','PMTo':'" + PMTo + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (data) {
},
error: function () {
alert("Error");
}
});
}
And my C# Code
[WebMethod]
public static Int32 AddAvailibility(Int32 ProviderId,string AvailDay,string AMFrom, string AMTo, string PMFrom,string PMTo)
{
string strconn = (string)ConfigurationSettings.AppSettings["ConnectionStringLocal"];
List<Speaclity> Detail = new List<Speaclity>();
string Success = string.Empty;
string SelectString = "Insert Into T_Provider(ProviderId, AvailDay, AMFrom, AMTo, PMFrom, PMTo) values ('" + ProviderId + "','" + AvailDay + "','" + AMFrom + "','" + AMTo + "','" + PMFrom + "','" + PMTo + "') ";
SqlConnection cn = new SqlConnection(strconn);
cn.Open();
SqlCommand cmd = new SqlCommand(SelectString, cn);
int result = cmd.ExecuteNonQuery();
if (result != 0)
{
Success = "True";
}
else
{
Success = "False";
}
return result;
}