错误:SyntaxError:DOM异常12 setRequestHeader @ [本机代码]

Jon*_*wak 7 iphone http-headers cors angularjs

我正在使用Phonegap和AngularJS,CORS_REST开发Android和IOS的移动应用程序.我几乎掌握了Android上标题的所有功能.在使用GapDebug在iPhone上进行测试时.

以下是身份验证代码的示例:

$http.post('someurlhere', {username: username, password: password})
                        .then(function (response) {
                            if(!response.IsAuthenticated) {
                            alertsManager.addAlert('Username or password is incorrect', 'alert-danger');
                        }
           callback(response);
                         console.log(response);
        });
Run Code Online (Sandbox Code Playgroud)

我得到一个错误:

SyntaxError:DOM异常12_IMG

如果有人能请求帮助我会非常感激.

谢谢:

小智 17

请检查标题参数,iOS9不接受http标题中的值,这些参数在值的开头有空格.例:

"令牌":"Token12345"=>错误的
"令牌":"令牌12345"=>正确

我希望这可以帮助你.

  • 很棒!如果它对其他人有用:我认为尾随空格也会导致此错误.例如,包括这样的标题:"授权:承载" (5认同)