循环通过ajaxcallback(WCF服务) [英] Looping through ajaxcallback (WCF Service)

查看:70
本文介绍了循环通过ajaxcallback(WCF服务)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在通过task使用for循环,这是json对象响应。在这个循环中,我调用了一个函数来使用ajaxcallback(WCF服务)来保存任务。但问题是插入/更新行在表中随机影响(SQL Server)。



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).

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

推荐答案

.ajax ({
类型: POST
url: localhost / MyService / Task.svc / SaveTask
data:para,
contentType: application / json; charset = utf-8
dataType: jsonp
async: false
成功:功能(数据){
// 警报(的Suc cessfully添加任务);
},
错误: function (msg){
alert( 失败);
}
});
}
.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


这篇关于循环通过ajaxcallback(WCF服务)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆