I have this lines of code that send multiple ajax request to wcf
$(".cWarpO").each(function () {
if ($(this).find(".newId").length > 0) {
counter++;
var Mapping = new Array();
Mapping[0] = counter;
Mapping[1] = $(this).find(".idN").html(); //new id
Mapping[2] = $(this).find(".idO").html();
Mapping[3] = newCourseId;
Mapping[4] = courseOldId;
Mapping[5] = isGenric;
Mapping[6] = oldGenricCourse;
$.ajax({
url: "/WebServices/general.svc/mappingCourses",
type: "POST",
data: JSON.stringify({ Mapping: Mapping }),
dataType: "json",
contentType: "application/json; charset=utf-8",
success: function (data) {
}
});
}
});
the webservice operation is update the db. Since the jquery ajax is work unsynchronized it's sending the server multipal request that end in error:"An operation was attempted on something that is not a socket"
I thins it's because the database is trying to open new connection every time.
Any idea how to loop on the array in a synchronized way?
Thanks
Baaroz