javascript - PhoneGap Ajax 请求在使用 AT&T 数据时返回 502(错误的网关),但不使用 WiFi

标签 javascript jquery ios api cordova

使用 PhoneGap 制作 iOS 应用程序,我正在做一些非常简单的事情(向远程 API 发出 ajax 请求)。在我的物理设备 (iPhone 4) 上进行测试时,当我使用 WiFi 发出请求时一切正常,但是当我通过 AT&T 数据计划发出请求时,我收到 502 错误网关响应(如下)。我觉得它在 PhoneGap 连接类中,但我可能是错的......我知道我的服务器正在正确接收请求,因为它在我的数据库中创建了一个实例在任何一个数据连接上,它只是在 AT&T 上响应很无聊数据。

这是我的 AJAX 打印输出和错误参数

$.ajax(
{
  url : 'http://remotehost.com/api/users/login',
  type : 'POST',
  dataType : 'json',
  data : $('#user_login').serializeArray(),
  success : function(result)
  {
  }
});

2011-10-10 00:05:12.983 Emoome[481:707] [INFO] Object:
readyState = 4
setRequestHeader = function (a, b) {t===0&&(l[a.toLowerCase()]=b);return this;}
getAllResponseHeaders = function () {return t===2?m:null;}
getResponseHeader = function (a) {var b;if(t===2){if(!n){n={};while(b=bs.exec(m))n[b[1].toLowerCase()]=b[2]}b=n[a.toLowerCase()]}return b||null;}
abort = function (a) {a=a||"abort",o&&o.abort(a),w(0,a);return this;}
promise = function (a, c) {if(a==null){if(e)return e;e=a={}}c=z.length;while(c--)a[z[c]]=b[z[c]];return a;}
isRejected = function () {return c||b;}
isResolved = function () {return c||b;}
fail = function () {if(!e){var c=arguments,g,h,i,j,k;b&&(k=b,b=0);for(g=0,h=c.length;g<h;g++)i=c[g],j=d.type(i),j==="array"?f.done.apply(f,i):j==="function"&&a.push(i);k&&f.resolveWith(k[0],k[1])}return this;}
done = function () {if(!e){var c=arguments,g,h,i,j,k;b&&(k=b,b=0);for(g=0,h=c.length;g<h;g++)i=c[g],j=d.type(i),j==="array"?f.done.apply(f,i):j==="function"&&a.push(i);k&&f.resolveWith(k[0],k[1])}return this;}
then = function (a, c) {b.done(a).fail(c);return this;}
success = function () {if(!e){var c=arguments,g,h,i,j,k;b&&(k=b,b=0);for(g=0,h=c.length;g<h;g++)i=c[g],j=d.type(i),j==="array"?f.done.apply(f,i):j==="function"&&a.push(i);k&&f.resolveWith(k[0],k[1])}return this;}
error = function () {if(!e){var c=arguments,g,h,i,j,k;b&&(k=b,b=0);for(g=0,h=c.length;g<h;g++)i=c[g],j=d.type(i),j==="array"?f.done.apply(f,i):j==="function"&&a.push(i);k&&f.resolveWith(k[0],k[1])}return this;}
complete = function () {if(!e){var c=arguments,g,h,i,j,k;b&&(k=b,b=0);for(g=0,h=c.length;g<h;g++)i=c[g],j=d.type(i),j==="array"?f.done.apply(f,i):j==="function"&&a.push(i);k&&f.resolveWith(k[0],k[1])}return this;}
statusCode = function (a) {if(a){var b;if(t<2)for(b in a)k[b]=[k[b],a[b]];else b=a[v.status],v.then(b,b)}return this;}
responseText = <html><body><h1>502 Bad Gateway</h1>
    The server returned an invalid or incomplete response.
    </body></html>

status = 502
statusText = error

最佳答案

我终于想通了该死的问题。与 AT&T 或 PhoneGap 无关......好吧仍然不确定前者是否不负责任,因为 AT&T 是可疑的......问题实际上出在我的 CodeIgniter REST 服务器中 - 我的应用程序正在为每次登录创建一个新的 session 条目请求(ajax POST 请求),当通过 AT&T 的线路返回时,我的应用程序认为这是一个 502 错误,因为它没有看到 cookie 或 session 数据。

关于javascript - PhoneGap Ajax 请求在使用 AT&T 数据时返回 502(错误的网关),但不使用 WiFi,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7709717/

相关文章:

javascript - (为什么)使用类似 jQuery 的选择器并执行其中一个方法比查找命名函数更快?

jQuery $.ajax 不在 IE 中调用 ASP.NET Web 服务方法

javascript - 文件被存储几次而不是一次

ios - 动画 UIWebView 在动画期间不响应触摸

objective-c - 与一个实体有多种关系而没有反向?

ios - 从 NSDictionary 检索键/值对会导致数据不正确并且还会崩溃

javascript - "right"处理迟到响应的方法是什么

javascript - jQuery datepicker 用一位数字解析年份

javascript - 如何在 node.js 中运行 jQuery

javascript - 为什么 outerWidth 不适用于 jqgrid 行和列?