chrome,firefox下面运行都很正常,唯独在safari下会爆SyntaxError: DOM Exception 12错误:
[Error] Error: SyntaxError: DOM Exception 12
setRequestHeader@[
native code]
http:
//localhost:8989/app/js/base.js:40967:27
http:
//localhost:8989/app/js/base.js:19014:33
forEach@http:
//localhost:8989/app/js/base.js:9537:24
http:
//localhost:8989/app/js/base.js:19012:14
sendReq@http:
//localhost:8989/app/js/base.js:18873:21
serverRequest@http:
//localhost:8989/app/js/base.js:18589:23
processQueue@http:
//localhost:8989/app/js/base.js:22454:29
http:
//localhost:8989/app/js/base.js:22470:39
$eval@http:
//localhost:8989/app/js/base.js:23672:28
$digest@http:
//localhost:8989/app/js/base.js:23488:36
$apply@http:
//localhost:8989/app/js/base.js:23777:31
bootstrapApply@http:
//localhost:8989/app/js/base.js:10661:21
invoke@http:
//localhost:8989/app/js/base.js:13409:22
doBootstrap@http:
//localhost:8989/app/js/base.js:10659:20
bootstrap@http:
//localhost:8989/app/js/base.js:10679:23
angularInit@http:
//localhost:8989/app/js/base.js:10573:14
http:
//localhost:8989/app/js/base.js:35510:16
fire@http:
//localhost:8989/app/js/base.js:3094:35
fireWith@http:
//localhost:8989/app/js/base.js:3206:11
ready@http:
//localhost:8989/app/js/base.js:3412:24
completed@http:
//localhost:8989/app/js/base.js:3428:14
这是个什么error?没见过baidu一下有了:
DOMException是W3C DOM核心对象。
DOMException接口表示一个处理的错误,当一个操作不可能执行的时候,会抛出一个异常。
例如试图创建一个无效的DOM, 或通过一个不存在的节点作为参数节点操作方法。
SYNTAX_ERR code 12 --> 无效或非法的字符串被指定。
具休介绍可以到些链接查看: http:
//www.zhangxinxu.com/wordpress/2012/05/w3c-dom-domexception-object/
先从error stack中找到出错的地方,在angular-file-upload-all.js中的以下位置:
1 var key, i;
2 function patchXHR(fnName, newFn) {
3 window.XMLHttpRequest.prototype[fnName] = newFn(window.XMLHttpRequest.prototype[fnName]);
4 }
5
6
if (window.XMLHttpRequest && !window.XMLHttpRequest.__isFileAPIShim) {
7 patchXHR('setRequestHeader', function (orig) {
8
return function (header, value) {
9
if (header === '__setXHR_') {
10 var val = value(
this);
11
// fix for angular < 1.2.0
12
if (val
instanceof Function) {
13 val(
this);
14 }
15 }
else {
16 orig.apply(
this, arguments);
17 }
18 }
19 });
20 }
出错的位置在第16行,把header打出来看了一下,Authorization的值是这样的'Token '的,后面多了一个空格,果断删除掉空格再试,不爆错了,原来是空格惹的祸,为什么会出错呢,想去看看这个orig的内容是什么,可碰到[
native code],这个估计是c++的code,这个要如何看得到内容呢,问题是解决了,但还未探清问题的源头,又是c代码,请高人指点。