簡體   English   中英

使用ashx和HTML

[英]Working with ashx and HTML

大家好,我是ajax編程和asp.net的新手

我有一個.ashx文件,該文件可以將文件上傳到服務器。 我正在如下的html頁面中進行ajax調用,並且在Visual Studio中確實可以正常工作

$.post("FileHandler.ashx", function (data) {
}

現在,我已將.ashx和.html文件復制到服務器(inetpub / wwwroot / MyPage)上,然后打開html頁面以檢查功能,但是這次文件沒有上傳,並且在網絡標簽的chrome調試器中,我在下面看到FileHandler.ashx的信息

方法:POST狀態:(已取消)

我做錯了嗎,請幫忙

您可以使用以下方式:

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(){}
});

更多文件。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM