I just updated my cordova version. When I run
cordova -v
It outputs version 5.0.0
On the older version of Cordova I had (I actually don't remember what version that was) I was able to use AJAX to request data from a given URL. However, after updating the Cordova version, it no longer works. I have made no edit to the code after this update, so I'm guessing something in the new Cordova version is preventing requests from going through.
I have added the following access grants in my config.xml file:
<access origin="*" /> <allow-intent href="http://*/*" /> <allow-intent href="https://*/*" /> <allow-intent href="tel:*" /> <allow-intent href="sms:*" /> <allow-intent href="mailto:*" /> <allow-intent href="geo:*" /> <platform name="android"> <allow-intent href="market:*" /> </platform>
but still no luck.
Has anyone come across a similar issue? Any idea how I can get it working again?
Thanks,
URL is not required, if you make call to current page.
You can move Request 2 into a function and this JS code will call the Request2 function after given interval of time (milliseconds), I have set it to 5 seconds for now. Show activity on this post. Applied to your code it might looks something like this: $(document).
ajax() Function. The url parameter is a string containing the URL you want to reach with the Ajax call, while settings is an object literal containing the configuration for the Ajax request. In its first form, this function performs an Ajax request using the url parameter and the options specified in settings .
What's AJAX? AJAX stands for Asynchronous JavaScript And XML. In a nutshell, it is the use of the XMLHttpRequest object to communicate with servers. It can send and receive information in various formats, including JSON, XML, HTML, and text files.
Turns out I was just missing the following plugin:
cordova-plugin-whitelist
After I installed it, rm the android platform, re-added the android platform, build and run, it worked!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With