我使用ashx处理程序上传数据和图像,它们工作正常。
但是我在ajax中的成功函数没有被执行
见这里:
$.ajax({
type: "POST",
url: "../Scripts/uploadify/UploadHandler.ashx",
contentType: false,
processData: false,
data: imag,
success: function(data){
console.log(data.bb);
alert('hii');
}
});
ASHX:
public void ProcessRequest(HttpContext context)
{
HttpPostedFile PostedFile = context.Request.Files[0];
if (!(PostedFile == null))
{
|
|
}
context.Response.ContentType = "application/json";
string bb = PostedFile.FileName;
context.Response.Write(bb); //im getting bb name correctly suppose 'koyla.jpg'
context.Response.StatusCode = 200;
}
public bool IsReusable
{
get
{
return false;
}
}
我没有获得bb成功功能,警报甚至没有执行.. ???
更新
var fileUpload = $("#image").get(0);
var files = fileUpload.files;
var imag = new FormData();
for (var i = 0; i < files.length; i++) {
imag.append(files[i].name, files[i]);
imag.append('Data',JSON.stringify({ objEnt: args }));
}