Cordova JQuery AJAX 不工作

use*_*214 3 ajax jquery jquery-mobile cordova

经过谷歌搜索几个小时后,我必须写下 cordova(CLI 5.3.3) 应用程序在通过 jquery AJAX 调用时返回未找到的页面。

我已经按照白名单插件( https://github.com/apache/cordova-plugin-whitelist )中的所有步骤进行操作,但仍然没有运气。

我已经将这些行包含在 config.xml 中

<access origin="*" />
<allow-navigation href="*" />
Run Code Online (Sandbox Code Playgroud)

还包括 CSP 等

<meta http-equiv="Content-Security-Policy" content="default-src 'self' https:">
Run Code Online (Sandbox Code Playgroud)

AJAX请求就像

$.ajax({
                    beforeSend: function() { $.mobile.loading("show"); }, //Show spinner
                    complete: function() { $.mobile.loading("hide"); }, //Hide spinner
                    url: weburl+"lgoin.php",                        
                    data: { email: $("#txtemail").val(), password: $("#txtpassword").val()},
                    type: "POST",                       
                    success: function(data) {                       
                        var response=$.parseJSON(data);                         
                        }                           
                    },                      
                    error: function (jqXHR, exception) {
                        var msg = '';
                        if (jqXHR.status === 0) {
                            msg = 'Not connect.\n Verify Network.';
                        } else if (jqXHR.status == 404) {
                            msg = 'Requested page not found. [404]';
                        } else if (jqXHR.status == 500) {
                            msg = 'Internal Server Error [500].';
                        } else if (exception === 'parsererror') {
                            msg = 'Requested JSON parse failed.';
                        } else if (exception === 'timeout') {
                            msg = 'Time out error.';
                        } else if (exception === 'abort') {
                            msg = 'Ajax request aborted.';
                        } else {
                            msg = 'Uncaught Error.\n' + jqXHR.responseText;
                        }
                        alert(msg);
                    },
                });
Run Code Online (Sandbox Code Playgroud)

AJAX 请求总是以错误回调中的消息结束,例如“未找到请求的页面。[404]”

注意:-- 我已经使用 Avance REST API 扩展测试了 Web 服务并且运行良好

谁能帮我解决这个问题。

感谢您提前抽出时间并考虑。-奈蒂克

Ahm*_*yaz 5

我刚刚在 AndroidManifest.xml 的应用程序标签中添加了这一行

android:usesCleartextTraffic="true" 
Run Code Online (Sandbox Code Playgroud)

这对我有用