【发布时间】:2016-08-10 01:17:59
【问题描述】:
每当我启动我的应用程序并在前几次尝试中单击登录时,登录都会尝试向服务器发送 POST http。但是 $http 总是(每次)在第一次尝试时返回 NULL。有时如果快速完成几次尝试后仍然为 NULL。但后来,一切都好。
我不明白,为什么 $http 最初返回错误响应 NULL ??
这是我的登录控制器在做 http 帖子
登录控制器 (LoginCtrl) https://gist.github.com/anonymous/771194bc5815e4ccdf38b57d6158853f
var req = {
method: 'POST',
url: baseURL,
data: postObject,
//timeout: 5000
};
这里的错误为 NULL:
}).error(function(err) {
我不知道它是否是 CORS,但我在 config.xml 中设置了这个
<access origin="*" />
我的 config.xml https://gist.github.com/anonymous/b2df3a857338d14ec3fcd6dda776e212
有什么想法吗? 我使用离子 1.7.14 在 iOS 9.3.1 设备上
更新
我已将问题代码放在这里。可以先注销到登录屏幕。在用户名/密码字段中输入任何内容,失败后单击登录,第二次或第三次尝试将成功。
https://github.com/axilaris/ionic_null_http_problem
到目前为止的一些故障排除:我注意到 http post 请求被调用了两次。不知道为什么。
使用 $http.post.then 更新了代码但仍然具有相同的效果
$http.post(baseURL, postObject).then(function successCallback(response)
response has NULL data --> Object {data: null, status: 0, config: Object, statusText: ""}
【问题讨论】:
标签: http ionic-framework null