2015-12-22 31 views
4

工作我正在开发一个应用程序AngularJS,我已经实现了一个简单的登录API调用。 API在除Safari之外的所有浏览器中都给出了响应。

我的登录API调用看起来像这样

$http.post(config.login, { 
     email: username, 
     password: password 
    }) 
    .then(function (response) { 
      callback(response); 
     }, 
     function (response) { 
      callback(response); 
     }); 

我得到的Safari以下响应。

enter image description here

我采用了棱角分明V1.4.8一个Safari浏览器9.0版(11601.1.56)

上怎么回事不对任何线索?

+0

[SYNTAX_ERR:DOM异常12 - 嗯(http://stackoverflow.com/q/7315162/2333214),你可能没有HTML5的doctype ..? –

回答

3

这让我发疯。 首先,我下载angular.js文件,然后搜索“xhr.setRequestHead”。所有问题都在这里。 我试着把一些日志看看发生了什么。

forEach(headers, function(value, key) { 
    key = key.trim();// trim the key 
    value = value.trim();// trim the value 
    console.log("******************** key: " + key); 
    console.log("******************** value: " + value); 
    console.log('value: Basic vs ' + value+ ' equal: '+ (value==="Basic")); 
    console.log('value.length: ' + value.length); 
    if (isDefined(value)) { 
     xhr.setRequestHeader(key, value); 
    } 
}); 

我发现angularjs自动把报头“授权”:“基本”在但是“基本”的字符串的长度为6不5. 因此,使用密钥= key.trim()和值=值.trim()解决了问题。

让我知道这是否帮助。

+0

这对我很有帮助。谢谢。 –