【问题标题】:REST service is not working with $.Ajax() of type POSTREST 服务不适用于 POST 类型的 $.Ajax()
【发布时间】:2014-01-22 06:04:51
【问题描述】:

我正在使用 REST 服务将数据从我的 Cordova 应用程序发布到服务器。 相同的服务适用于 $.post(),但不适用于类型为“POST”的 $.Ajax()。 谁能告诉我为什么??

【问题讨论】:

  • 你能发布你的完整的ajax编码吗?

标签: javascript rest jquery cordova


【解决方案1】:

您是否为您的 Ajax 方法设置了type : 'POST',如下所示..

$.ajax({ type : 'POST', ....});

【讨论】:

  • $.ajax({ url : , data : JSON.stringify(JSonData), type : 'POST', contentType : "text/html", dataType : 'json', 成功:函数(结果){},标题:{“授权”:“基本”+ myBase64variable,“内容类型”:“应用程序/json”}错误:函数(RcvData,错误){console.log(RcvData);}} );
  • 我认为您的 Content-Type 有问题;也许您在标题中添加的第二个不是必需的。但是,为了获得正确的原因,请安装 firebug 或使用 google chrome 开发人员工具来识别当您使用 &.post 或使用 &.ajax 时客户端和服务器之间真正传递的内容。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2019-06-19
  • 2016-06-17
  • 2018-11-21
  • 1970-01-01
  • 2015-08-07
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多