大家好,我是ajax编程和asp.net的新手
我有一个.ashx文件,它处理上传到服务器上的文件。我在一个html页面中进行了一个ajax调用,如下所示,它在visual studio中工作得很好。
$.post("FileHandler.ashx", function (data) {
}现在,我已经将.ashx和.html文件复制到服务器上(inetpub/wwwroot/MyPage),然后打开html页面检查功能,但这次文件没有上传,在chrome调试器的网络选项卡中,我看到以下有关FileHandler.ashx的信息
方法: POST状态:(已取消)
是不是我做错了什么,请帮帮忙
发布于 2015-04-22 17:26:36
您可以使用类似以下内容:
var fd = new FormData();
fd.append("filename", $('#file').val()); // append the file in the form data.
$.ajax({
url: "FileHandler.ashx",
type: "POST",
data: fd,
processData: false, // tell jQuery not to process the data
contentType: false // tell jQuery not to set contentType
success:function(){},
error:function(){}
});https://stackoverflow.com/questions/29792998
复制相似问题