ajax跨域上传文件加了xhr报不支持options错误

用ajax跨域上传文件不加xhr就能请求成功,为了实现进度条功能在ajax里面加了xhr就报错了

 

$.ajax({

url: "http://localhost:823/api/FileStream/Upload",

type: "post",

contentType: false,

cache: false,

processData: false,

contentType: false,

data: formdata,

xhr:function(){ var myXhr = $.ajaxSettings.xhr(); if (myXhr.upload) { myXhr.upload.addEventListener("progress", progressHandlingFunction,false); } return myXhr; },

success: function (text){ if (text == "success") { alert("上传成功"); }


HUWWW
浏览 946回答 1
1回答

慕无忌1623718

可能是Access-Control-Allow-Origin:*引起的,建议将*改为http://localhost:63695试试
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript