请原谅我使用的任何不正确的技术词汇,我是AJAX / Jquery的新手。
我有一个AJAX函数。它被用来执行一个服务器端功能,但它没有做任何事情。我已多次检查我的代码。我在不同的位置使用类似的代码,一个工作正常。
(我在html页面中导入了必要的脚本) 这是AJAX的功能:
function pass_on() {
hide_div("#outer_layout", 500);
get_din();
claim_no = document.getElementById("claim_no_label").value;
tempdin = document.getElementById("temp_din_label").value;
var data = {};
data.ReqType = real_index;
//and so on with rest of the variables.
$.ajax({
type: "POST",
url: "claim_form.aspx/submit",
data: data,
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function() {
window.location = "Defualt.aspx";
},
failure: function() {
alert("FAIL!");
}
});
}
以下是asp.net页面中的相应函数:
<System.Web.Services.WebMethod()> _
Public Shared Function submit(ByVal ReqType As String, ByVal Claim_Num As String, ByVal Comments As String, ByVal PaymentDate As String, ByVal Payee As String, ByVal IRSNum As String, ByVal AddrStreet1 As String, ByVal AddrStreet2 As String, ByVal AddrCity As String, ByVal AddrState As String, ByVal AddrZip As String, ByVal PaymentAmount As String, ByVal FinalPaymentType As String, ByVal NAVGPercentSettlement As String, ByVal ReasonMemo As String, ByVal ProductCode As String, ByVal DeductAmount As String, ByVal DeductType As String, ByVal ClosedStatus As String, ByVal ReassignTo As String, ByVal TempDin As String) As String
'Puts values in the DB.
对不起,如果文本格式不是很好,这件事拒绝对我有效:P
有人能指出我(可能是显而易见的)错误吗? 如果需要更多细节,我会根据要求提供:)
编辑:更改了代码以反映更改....仍然无效。
答案 0 :(得分:0)
我建议改变:
'{ReqType: "' + real_index + '", Claim_Num: "' + claim_no + '", Comments: "' + comment_box_form + '", PaymentDate: "' + f4_pay_date + '", Payee: "' + f4_payee + '", IRSNum: "' + f4_irs + '", AddrStreet1: "' + f4_a_1 + '", AddrSteet2: "' + f4_a_2 + '", AddrCity: "' + f4_a_c + '", AddrState: "' + f4_a_s + '", AddrZip: "' + f4_a_z + '", PaymentAmount: "' + f4_pay_amount + '", FinalPaymentType: "' + f4_final + '", NAVGPercentSettlement: "' + f4_navg_set + '", ReasonMemo: "' + f4_reason + '", ProductCode: "' + f4_product + '", DeductAmount: "' + f3_amount + '",DeductType: "' + f3_loss + '", ClosedStatus: "' + f3_close + '", ReassignTo: "' + reassign_to + '", TempDin: "' + tempdin + '" }'
到:
var data = {};
data.ReqType = real_index;
data.Claim_Num = claim_no;
data.Comments = comment_box_form;
... etc
然后在你的ajax:
data: data,
答案 1 :(得分:0)
这一行
data: '{ReqType: "' + real_index + '", Claim_Num: "' + claim_no + '", Comments: "' + comment_box_form + '", PaymentDate: "' + f4_pay_date + '", Payee: "' + f4_payee + '", IRSNum: "' + f4_irs + '", AddrStreet1: "' + f4_a_1 + '", AddrSteet2: "' + f4_a_2 + '", AddrCity: "' + f4_a_c + '", AddrState: "' + f4_a_s + '", AddrZip: "' + f4_a_z + '", PaymentAmount: "' + f4_pay_amount + '", FinalPaymentType: "' + f4_final + '", NAVGPercentSettlement: "' + f4_navg_set + '", ReasonMemo: "' + f4_reason + '", ProductCode: "' + f4_product + '", DeductAmount: "' + f3_amount + '",DeductType: "' + f3_loss + '", ClosedStatus: "' + f3_close + '", ReassignTo: "' + reassign_to + '", TempDin: "' + tempdin + '" }',
不正确,马上我可以看到你错过了一个“在ReqType之前和:不应该在引号内并且'不应该在那里
data: {"ReqType": real_index, "Claim_Num" :claim_no, etc