??yy 2015-02-20 13:17 采纳率: 0%
浏览 78

科尔多瓦阿贾克斯(Cordova Ajax)错误要求

I've got a simple server app running on Heroku that I'm making ajax calls to from a Cordova app. I've setup CORS on the server app and I can call the server from my browser without any problems. However, when I call the server using the exact same code from within Cordova I get a Bad Request error!!

$.ajax({
    url: 'http://{myserver}/{function}',
    type: 'GET',
    data: { mydata... },
    success: function(resp){ alert("success"); },
    error: function(err) { alert(err.statusText); }
});

I've tried adding crossDomain: true and dataType: 'jsonp', it makes no difference. I've also checked that all domains are whitelisted in Cordova <access origin="*" />

Why can't I access the server from Cordova when I can access it from my browser?

  • 写回答

1条回答 默认 最新

  • weixin_33725722 2015-02-20 13:37
    关注

    Figured it out! The reason was that I has a misspelling in data: { ... } so one of the parameters was missing.

    评论

报告相同问题?

悬赏问题

  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容