Software Archive
Read-only legacy content
17061 Discussions

Cordova Ajax cut URL short [Solved]

Jesper_S_
Beginner
780 Views

Hi!

I refer to my stackoverflow thread: http://stackoverflow.com/questions/28761941/cordova-doesnt-add-data-to-url-ajax


In shortage:

Browser, emulator, legacy hybrid build, cordova IOS works great. The url which is sent to the webservice is correctly formatted.

In the Cordova Android build, my url is missing the data parameters after the callback in the link.

 

No parameters in request url: http://oi60.tinypic.com/21jvb5y.jpg

In the browser the ajax is working and sending an url ending in this: LogonUser?callback=jQuery19105695250731240461_1425028837473&username=MyUserName&password=Secret&environment=Dev

Thank you guys!

SOLVED: I tried using static values instead of the cookies and that solves the problem. For some reason Cordova didn't like dem cookies...

 


 

0 Kudos
3 Replies
Jesper_S_
Beginner
780 Views

I see that when I'm using Cordova at the device, the Response header is set to Content-type text/plain, while using the emulator it says application/json. How can that be? It might be related

 

 

UPDATE:

I am now most certain that my problem is due to the Cordova build sending the get/post as type: text/plain.

I have tried to force it in the Ajax with contentType: application/json but with no luck. And I doubt there is any more configuration to do server side due to the fact that it is working in the simulator and with the legacy hybrid build. Any clues?

0 Kudos
Swati_S_Intel1
Employee
780 Views

Hello,

Which device are you testing on? Which version of Android? Are you sending a POST request?

I have used cordova build with other projects with ajax and it works fine.

Please send the snippet of your code or a zip file of your project that I can look at.

Thanks,

Swati

0 Kudos
Jesper_S_
Beginner
780 Views

I'm so happy right now. This week couldn't have started any better. I SOLVED IT.

The problem was in the Data {}. For some reason, Cordova (on the actual device) can't handle cookies :s This works on iOS, emulator, legacy hybrid but not the actual cordova.
By entering static values both Get (jsonp) and Post is working.

Time to celebrate. Thank you Intel for an awesome dev tool <3

 

@SWATI for future reference: I was using v5.0.1 on a Nexus 9. But I have tried this on different devices and older Android versions. 

 

 

0 Kudos
Reply