Javascript 403禁止从Cordova 5.0.0应用程序发布AJAX帖子

Javascript 403禁止从Cordova 5.0.0应用程序发布AJAX帖子,javascript,android,ajax,cordova,cors,Javascript,Android,Ajax,Cordova,Cors,我有一个非常简单的Cordova应用程序,它试图做一篇AJAX文章 请求的URL simple.php如下所示: <?php header('Access-Control-Allow-Origin: *'); die ( json_encode ( array('result'=>'ok') ) ); ?> 当我在本地(从文件://)访问此HTML页面时,我得到XMLHttpRequest无法加载http://drawonthe.net/simple.php. 请求的资源上不

我有一个非常简单的Cordova应用程序,它试图做一篇AJAX文章

请求的URL simple.php如下所示:

<?php
header('Access-Control-Allow-Origin: *');
die ( json_encode ( array('result'=>'ok') ) );
?>
当我在本地(从文件://)访问此HTML页面时,我得到
XMLHttpRequest无法加载http://drawonthe.net/simple.php. 请求的资源上不存在“Access Control Allow Origin”标头。因此,不允许访问源“null”。响应的HTTP状态代码为403。
,它返回
{“readyState”:0,“status”:0,“statusText”:“error”}

当我通过托管在本地服务器上访问HTML页面时,它可以毫无怨言地工作。(正确的回答:
“{\”结果\“:\”确定\“}”

当我在Android或iOS设备上作为Cordova应用程序运行它时,我得到
{“readyState”:4,“responseText”:“…布拉赫布拉赫…403禁止…,“状态”:403,“状态文本”:“禁止”}

发生什么事了?
如何从手机应用程序发出此请求?

当我在服务器上禁用ModSecurity时,此问题已得到解决

对我来说,我可以通过cPanel访问我的主机:

cPanel>Security>ModSecurity

我希望这对其他人有帮助。

感谢@jcesarmobile指出问题出在服务器上。

您在哪里访问此html页面?在浏览器中还是在手机浏览器中?在哪里显示成功?如果我从本地服务器运行,或者实际上从任何服务器运行,例如,如果我将其上载到此处:我看不出您所做的工作不起作用的原因,但也许您是合作的uld在cordova plugin legacy whitelist enstead of cordova plugin whitelist方面运气更好?@QuickFix-一个好建议-我很兴奋,并立即尝试了它-唉,没有,同样的问题仍然存在。您收到了服务器的响应,所以问题出在服务器上
<head>

    <script src="jquery.js"></script>


    <script>

    $(document).ready( function() {

        $.ajax(
        {
            type: 'POST',
            url: 'http://drawonthe.net/simple.php',
            contentType: 'text/plain',
            xhrFields: {
                withCredentials: false
            },

            success: function(res) {
                alert('got this res : ');
                alert(JSON.stringify(res));
            },

            error: function(err) {
                alert('got this fail : ');
                alert(JSON.stringify(err));
            }

         });

    });

    </script>

</head>


<body>
</body>
<content src="index.html" />
<access origin="*" />
<allow-intent href="*" />
<allow-navigation href="*" />
<access origin="content:///*" />
   <meta http-equiv="Content-Security-Policy" content="default-src *; script-src * 'unsafe-eval' 'unsafe-inline'; connect-src *; img-src *; style-src * 'unsafe-inline' ; media-src *; ">