Jquery.form(3.51.0-2014.06.20)fileupload在IE9中不起作用(sharepoint应用程序)

时间:2014-08-25 07:05:39

标签: javascript jquery json cors sharepoint-online

好的,在我开始之前让我说我确实看过SO和其他地方的几乎所有答案。 jq表单上传问题并确信此问题不同。

基本上发生的是文件上传正常,并以application / json格式返回响应,并带有来自上传控制器的ID。最初在IE中,响应提示下载并解决我将内容类型更改为text / json(text / html,text / xml)。现在它不再提示下载,但是当我尝试访问响应时查找返回值时,它显示为空。代码看起来像这样,xhr.responseText为空。

 $('#upload-file-data-form').ajaxSubmit({
                    xhrFields: { withCredentials: true },
                    url: url,
                    dataType: "json",
                    data: { DataItems : "some data" },
                    complete: function (xhr) {
                        var json = xhr.responseText;
                        var data = $.parseJSON(json);
                        onDone(data.d);
                    },
                    errors: function () {
                        onFail();
                    }
                });

返回的JSON的Fiddler摘录。

enter image description here

应用程序托管在SP中,并且上传发生在azure中的web api端点。由于这在chrome和IE11中运行良好,我假设这是IE9中的CORS问题。我现在已经搞乱了这两天以上了,而且我会为那些能够对此有所了解的人买一杯啤酒(不是开玩笑!:))。

干杯!

1 个答案:

答案 0 :(得分:0)

可能是,因为您的代码中存在语法错误:

data: { "some data" }

选择(提交对象)

data: { name: "firstname"}

或数组

data: ["some data"]