Apache Cordova Visual Studio 2015 Android Platform version 6.0.0. Ajax Request Failed

  • 1
  • Problem
  • Updated 4 years ago
Hi Team,
I am struggling for many days, to fix this issue which is making me nuts.

I am using Visual Studio 2015 for Apache Cordova. Recently I updated platform from 4 to 5.1.1 and then again updated with 6.0.0.

I am not able to hit ajax request using Device, normal Ripple using Chrome works fine.

I googled and tried every thing like added whitelist plugin, accessorigin and other suggestions to config.xml, added meta tags to html pages, allowed $.cors.true to ajax request, but nothing works, always get status= 0; and it seems it expects HTTPS request instead of Http.

I am using localhost or hosted server API url, but no luck.
Photo of Shyam Tomar

Shyam Tomar

  • 5 Posts
  • 0 Reply Likes

Posted 4 years ago

  • 1
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
Do you:
- include a reference to cordova.js in your html, without actually including such file in your assets?
- have both config.xml and index.html in the root of your zip
- have Hydration switched off
- wait for the deviceready event to fire before attempting to make any ajax call?
Photo of Shyam Tomar

Shyam Tomar

  • 5 Posts
  • 0 Reply Likes
I have all the files at right place except for hydration property, what is this and how can I enable? . This issues has occurred once I updated the update 6 for apache tools and then platform.
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
So you are building locally, not with PGB?
Photo of Shyam Tomar

Shyam Tomar

  • 5 Posts
  • 0 Reply Likes
Yes, using visual studio
Photo of JesseMonroy650 (Volunteer)

JesseMonroy650 (Volunteer), Champion

  • 3325 Posts
  • 122 Reply Likes
@Shyam,
the forum is for Phonegap Build not for IDEs like Visual Studio, Android Studio, Eclipse, and the such. Phonegap Build is a cloud-based build system by Adobe/Phonegap .

You should be aware that there are three (3) different systems for Corodova/Phonegap CLI, SDK or Build.

Hydration is intended to work with Phonegap Build. It is not intended for any IDEs. In addition it is a debugging tool not a production tool.

If you would like a debugging tool we can suggest others - that work with IDEs.

This FAQ should also help. Read the bold sentences.
Top Mistakes by Developers new to Cordova/Phonegap

Jesse
Photo of Kanchana Mathabaya Weerasnghe

Kanchana Mathabaya Weerasnghe

  • 1 Post
  • 0 Reply Likes
Hi
Shyam Tomar

Did you find a solution for AJAX CORS issue in Cordova. Please let me know
Photo of JesseMonroy650 (Volunteer)

JesseMonroy650 (Volunteer), Champion

  • 3325 Posts
  • 122 Reply Likes
@Kanchana,
There is no CORS issue with Phonegap. Phonegap does not use CORS.

Please start a new thread with your issue, please let us know:
- is this your first hybrid app?
- are you using Desktop App?
- are you using CLI, Build, or SDK? Please do not assume the answer, please read the link.

FWIW: the forum is for Phonegap Build not for IDEs like Visual Studio, Android Studio, Eclipse, and the such. Phonegap Build is a cloud-based build system by Adobe/Phonegap .

Thanks
Jesse
Photo of Shyam Tomar

Shyam Tomar

  • 5 Posts
  • 0 Reply Likes
Yes
Photo of Shyam Tomar

Shyam Tomar

  • 5 Posts
  • 0 Reply Likes
Yes
Photo of JesseMonroy650 (Volunteer)

JesseMonroy650 (Volunteer), Champion

  • 3325 Posts
  • 122 Reply Likes
@Shyam
"Yes" to what? There are three questions. They third questions is a multiple choice, not a yes or no question.

Please start a new thread.

Jesse