我努力了,但我无法弄清楚出了什么问题。我想通过ajax发送一些参数,但每次出错都是如此。我的代码是:
sendInsertValues : function(serviceCode, description, borrowerCoborrower, expiration, premiumValue,comissionValue,maxAge,companyCode) {
var callUrl = "http://localhost:9080/XA-UW0-PF/tmInsurance.do?method=add";
var date = new Date();
var time = date.getTime();
$.ajax({
type : "POST",
url : callUrl,
data: "serviceCode=" + serviceCode+
"&description="+ description +
"&borrowerCoborrower="+ borrowerCoborrower +
"&expiration="+ expiration+
"&premiumValue="+ premiumValue+
"&comissionValue="+comissionValue+
"&maxAge="+maxAge+
"&companyCode="+companyCode+
"&time="+time,
success: function(data, textStatus, jqXHR)
{
alert("Operation completed.");
window.close();
},
error: function(jqXHR, textStatus, errorThrown)
{
alert("Operation not completed.");
}
});
}
我希望有人可以帮助我。谢谢!
答案 0 :(得分:0)
数据应该是这样的
data:{ "serviceCode":serviceCode,
"description":description,
"borrowerCoborrower":borrowerCoborrower,
"expiration":expiration,
"premiumValue":premiumValue,
"comissionValue":comissionValue,
"maxAge":maxAge,
"companyCode":companyCode,
"time":time
}
答案 1 :(得分:0)
您需要将data
作为JSON
data: {
"serviceCode" : serviceCode,
"description": description,
"borrowerCoborrower": borrowerCoborrower,
"expiration": expiration,
"premiumValue": premiumValue,
"comissionValue": comissionValue,
"maxAge": maxAge,
"companyCode": companyCode,
"time" : time
}
答案 2 :(得分:0)
你试过了吗?
data: { 'serviceCode': serviceCode, 'description' ... }
只需将参数作为JSON对象传递。
答案 3 :(得分:0)
sendInsertValues : function(serviceCode, description, borrowerCoborrower, expiration, premiumValue,comissionValue,maxAge,companyCode) {
var callUrl = "http://localhost:9080/XA-UW0-PF/tmInsurance.do?method=add", data = {
"serviceCode" : serviceCode,
"description": description,
"borrowerCoborrower": borrowerCoborrower,
"expiration": expiration,
"premiumValue": premiumValue,
"comissionValue": comissionValue,
"maxAge": maxAge,
"companyCode": companyCode,
"time" : time
};
return $.post(callUrl, data).done(function(response) {
alert("Operation completed.");
window.close();
}).fail(function(error){alert("Operation not completed.");});
}