Click here to Skip to main content
15,891,253 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am using a for loop through "task", which is json object response. In this loop I have called a function to SAVE "task" using ajaxcallback (WCF Service). But problem is Insertion/Updation the rows are affecting randomly in tables(SQL Server).

JavaScript
for (var i = 0; i < tasks.length; i++) {
para = {taskName: task.Name, tasktype:TaskType }
SaveTask();
}

SaveTask()
{
$.ajax({
            type: "POST",
            url: "localhost/MyService/Task.svc/SaveTask",
            data: para,
            contentType: "application/json;charset=utf-8",
            dataType: "jsonp",
            async: false,
            success: function (data) {
                //alert("Successfully Added task");
            },
            error: function (msg) {
                alert("Failed");
            }
        });
}


I think while service is running, the next iteration starts, so it executes randomly.
If any met with the same issue please response ASAP.

Thanks
Posted
Comments
IpsitaMishra 5-Nov-14 1:31am    
You can pass the Task list at a time and do all the update operation in a single sql transaction.
Puneet Makode 5-Nov-14 1:44am    
thank you

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900