【发布时间】:2017-05-03 03:23:57
【问题描述】:
下面是我的ajax请求
function sendData() {
var formdata = new FormData();
var fileUpload = $("#txtUploadFile").get(0);
var files = fileUpload.files;
for (var i = 0; i < files.length; i++) {
formdata.append(files[i].name, files[i]);
}
formdata.append("PaymentDate", new Date());
$.ajax({
url: 'CCA_Form.aspx/SendData',
type: 'POST',
data: formdata,
contentType: false,
processData: false,
success: function () {
alert("Data Added Successfully");
},
error: function () {
alert("Error while inserting data");
}
});
}
而我的服务器方法是这样的
[WebMethod]
public static string SendData()
{//break point here
// code
return "return data";
}
ajax 方法总是显示成功消息和 webmethod 没有在服务器端命中。你能帮我在我的代码中遗漏什么吗? 提前致谢。
【问题讨论】: