【问题标题】:Phonegap Ajax method POST error 404 NOT FOUNDPhonegap Ajax 方法 POST 错误 404 NOT FOUND
【发布时间】:2018-03-12 03:00:18
【问题描述】:

Phonegap ajax 方法 GET 运行良好,但 POST 给出错误。我已尝试使用cordova-plugin-whitelist,但仍然没有找到错误 404。

这是我的 ajax 代码

function GetSlider(){
    serverRoot = "/js/ajax.php";
    $.ajax({
        type: "post",
        url: serverRoot,
        data: "act=GetSlider",
        dataType: "JSON",
        beforeSend: function(){
            $("#loading").show();
        },
        success: function(){
            $("#loading").hide();
        }
    });         
}

config.xml

<platform name="android">
    <allow-intent href="market:*" />
</platform>
<platform name="ios">
    <allow-intent href="itms:*" />
    <allow-intent href="itms-apps:*" />
</platform>
<plugin name="cordova-plugin-whitelist" spec="~1.2.2" />
<gap:plugin name="cordova-plugin-whitelist" source="npm" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<allow-navigation href="http://*/*" />
<allow-navigation href="https://*/*" />
<allow-navigation href="data:*" />
<allow-navigation href="dubailibrary.com*" />
<access origin="*" />

Check this screenshot

回复:Cannot POST /js/ajax.php

【问题讨论】:

  • 你正在调用一个本地的php文件,这是行不通的。您必须使用远程服务器,例如www.example.com/js/ajax.php
  • 感谢 Joerg 的工作。但是有什么解决方案可以在本地运行吗?
  • 你不能在 phonegap 应用上运行 php,你需要一个服务器。

标签: jquery ajax cordova http-status-code-404 phonegap-plugins


【解决方案1】:

尝试使用内容安全策略方法:Cordova Plugin Whitelist

【讨论】:

    猜你喜欢
    • 2019-04-06
    • 1970-01-01
    • 1970-01-01
    • 2023-03-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-06-09
    • 2023-03-05
    相关资源
    最近更新 更多