I'm happy to live!

          Develop with pleasure!

            BlogJava :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
            39 隨筆 :: 2 文章 :: 31 評(píng)論 :: 0 Trackbacks
               chrome,firefox下面運(yùn)行都很正常,唯獨(dú)在safari下會(huì)爆SyntaxError: DOM Exception 12錯(cuò)誤:
           [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
           


          這是個(gè)什么error?沒見過baidu一下有了:

          DOMException是W3C DOM核心對(duì)象。
          DOMException接口表示一個(gè)處理的錯(cuò)誤,當(dāng)一個(gè)操作不可能執(zhí)行的時(shí)候,會(huì)拋出一個(gè)異常。
          例如試圖創(chuàng)建一個(gè)無效的DOM, 或通過一個(gè)不存在的節(jié)點(diǎn)作為參數(shù)節(jié)點(diǎn)操作方法。

          SYNTAX_ERR code 12 --> 無效或非法的字符串被指定。

          具休介紹可以到些鏈接查看: http://www.zhangxinxu.com/wordpress/2012/05/w3c-dom-domexception-object/

          先從error stack中找到出錯(cuò)的地方,在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 }

          出錯(cuò)的位置在第16行,把header打出來看了一下,Authorization的值是這樣的'Token '的,后面多了一個(gè)空格,果斷刪除掉空格再試,不爆錯(cuò)了,原來是空格惹的禍,為什么會(huì)出錯(cuò)呢,想去看看這個(gè)orig的內(nèi)容是什么,可碰到[native code],這個(gè)估計(jì)是c++的code,這個(gè)要如何看得到內(nèi)容呢,問題是解決了,但還未探清問題的源頭,又是c代碼,請(qǐng)高人指點(diǎn)。 
          posted on 2015-12-17 17:04 Norsor 閱讀(1972) 評(píng)論(0)  編輯  收藏

          只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 和硕县| 梁河县| 大足县| 新宾| 德惠市| 千阳县| 白沙| 彭泽县| 茌平县| 安阳县| 礼泉县| 陆河县| 格尔木市| 西青区| 宝鸡市| 通江县| 芦溪县| 定日县| 栾川县| 岐山县| 肥西县| 阿瓦提县| 宁远县| 肃宁县| 栾川县| 九龙城区| 渑池县| 周至县| 乌拉特后旗| 清水河县| 梁河县| 木里| 辽宁省| 乌兰察布市| 唐河县| 平乐县| 安福县| 定陶县| 平阴县| 曲沃县| 台北市|