这是一个MyLinkButton
<a id="btnUpdateActivityD" style="margin: 10px 5px;" class="btn blue-soft pull-right">
<i class="fa fa-check fa-lg"></i> Ok
</a>
那些是Ajax代码
$("#btnUpdateActivityD").on('click', function () {
var activity = new ActivityObject(parseInt(activityId), $("#txtActivityNameD").val(), $("#txtActivityCodeD").val(), startDate, endDate, true, parseInt($("#ddlActivityTypeD").val()), parseInt($("#ddlActivityCompD").val()), parseInt($("#ddlActivityTrainerD").val()), parseInt($("#ddlActivityPlaceD").val()), $("#txtActivityDescD").val(), parseInt(activityTotalPerson), 1);
$.ajax({
type: "POST",
url: "ActivityDetail.aspx/UpdateActivity",
data: "{act:" + JSON.stringify(activity) + "}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (result) {
debugger;
},
error: function (result, textStatus, errorThrown) {
debugger;
//console.log(JSON.stringify(activityX));
//console.log("AJAX error: " + textStatus + ' : ' + errorThrown);
},
});
window.parent.closeActivityDetailModal();
window.parent.RefreshActivityList();
window.parent.toastrNotification("success");
});
大家好ajax post只能工作调试模式。如果项目正常运行,ajax post不起作用,捕获错误行并获得如result.responseText =“”的消息你能帮助我吗?我可以一次又一次地研究和审查我的文档,stacoverflow页面和代码块,但我没有解决。
答案 0 :(得分:1)
试试这段代码
$("#btnUpdateActivityD").on('click', function () {
var activity = new ActivityObject(parseInt(activityId), $("#txtActivityNameD").val(), $("#txtActivityCodeD").val(), startDate, endDate, true, parseInt($("#ddlActivityTypeD").val()), parseInt($("#ddlActivityCompD").val()), parseInt($("#ddlActivityTrainerD").val()), parseInt($("#ddlActivityPlaceD").val()), $("#txtActivityDescD").val(), parseInt(activityTotalPerson), 1);
$.ajax({
type: "POST",
url: "ActivityDetail.aspx/UpdateActivity",
data: "{act:" + JSON.stringify(activity) + "}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (result) {
window.parent.closeActivityDetailModal();
window.parent.RefreshActivityList();
window.parent.toastrNotification("success");
},
error: function (result, textStatus, errorThrown) {
debugger;
//console.log(JSON.stringify(activityX));
//console.log("AJAX error: " + textStatus + ' : ' + errorThrown);
},
});
});
因为您使用的是ajax,所以回调和操作必须成功或错误方法