Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ajax Command to request URL no longer working

Tags:

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,

like image 269
user3494561 Avatar asked Apr 20 '15 20:04

user3494561


People also ask

Can we use Ajax without URL?

URL is not required, if you make call to current page.

How do I send an Ajax request after some time?

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).

What does URL do in Ajax?

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 does Ajax GET request do?

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.


1 Answers

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!

like image 185
user3494561 Avatar answered Sep 18 '22 02:09

user3494561