Cordova Ajax请求待定

编程入门 行业动态 更新时间:2024-10-24 14:22:04
本文介绍了Cordova Ajax请求待定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我在这里遇到了很多问题。我有一个cordova应用程序,它工作正常,直到今天早上。我认为它与cordova 6.4.0的新更新有关。 每当我向我的API发送一个AJAX请求时,它仍会等待更多。我等了15分钟他们仍然没有回来。我更新了白名单插件,我在config.xml中添加了正确的信息:

Hi i'm having quite an issue here. I have a cordova app and it worked fine until this morning. I think it has something to do with the new update to cordova 6.4.0. Whenever I'm sending an AJAX request to my API and it stay in pending more for ever. I've waiting 15 minutes and they still havn't come back. I have the whitelist plugins updated, i added the correct info in the config.xml :

<plugin name="cordova-plugin-whitelist" spec="1" /> <allow-navigation href="*" /> <access origin="*" />

还有我的cordova和插件的版本

And there are the version of my cordova and plugins

cordova-plugin-compat 1.1.0 "Compat" cordova-plugin-file 4.3.0 "File" cordova-plugin-network-information 1.3.0 "Network Information" cordova-plugin-whitelist 1.3.1 "Whitelist" cordova-plugin-x-toast 2.5.2 "Toast" phonegap-plugin-push 1.8.0 "PushPlugin"

您对如何解决此问题有任何想法谢谢

Do you have any ideas on how to fix this Thanks

这是我用来发出Ajax请求的代码。我正在返回Ajax元素,所以我可以附加 .done()或 .fail()函数它。

Here is the code I am using to make Ajax request. I'm returning the Ajax element so I can attach a .done() or a .fail() function to it.

this.get = function($url, $data, $beforeSend) { /*if($url.indexOf('http') == -1) { $url = this.URL_API + $url; }*/ $url = this.URL_API + $url; if(typeof $data !== 'object') { this.error('Erreurs de type de donnée.'); } else { console.log($url); return $.ajax({ url: $url, method: 'GET', data: $data, beforeSend: function(xhr) { if(typeof utils.userdata !== "undefined") { xhr.setRequestHeader('X-API-KEY', utils.userdata.key); } xhr.setRequestHeader('Content-Type', 'application/json'); console.log(utils.userdata); console.log($data); if($beforeSend !== null && typeof $beforeSend == "function"){ $beforeSend(); } } }); } }

我还在添加X-API-KEY标题我的请求但不应该是问题。

I'm also adding an X-API-KEY header to my request but that shouldn't be the problem.

  • Nic
推荐答案

正如你所说,在将其更新为新版本的cordova之前它工作正常

As you said that it was working fine before updating it to new version of cordova

然后你可以用下面的命令降级它,检查一切是否正常工作。

Then you can downgrade it with the below command and check if everything working fine again or not.

$ sudo npm install -g cordova@6.2.0

如果问题仍然存在,那么你的ajax调用或您需要通过 postman 检查您的API,并检查它是否正常工作。

And if the problem remain same then there is the problem either from your ajax call or you need to check your API via postman and check if it is working fine or not.

更多推荐

Cordova Ajax请求待定

本文发布于:2023-11-27 06:55:55,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1637051.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:待定   Cordova   Ajax

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!