This is a migrated thread and some comments may be shown as answers.

Icenium 1.10 cordova 3.2 and ajax post

5 Answers 74 Views
AppBuilder Windows client
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Marco
Top achievements
Rank 1
Marco asked on 12 Dec 2013, 03:06 PM
Dear Telerik 
I updated my Icenium project from cordova 3.0 to 3.2.
In my code I have and ajax post to our company server and with cordova 3.2 does not work ( status error 0). If I go back to cordova 3.0 the same code works perfectly.
Can you please help me? It could be a wrong conversion of the internet permission?

Marco

5 Answers, 1 is accepted

Sort by
0
Pier Alberto
Top achievements
Rank 1
answered on 13 Dec 2013, 10:55 PM
I've exactly the same problem. On iOS the app works perfectly (also with the new StatusBar plugin which solved a big problem). Unfortunately when ran on Android, every Ajax call fails with Status=0.
In my mobileinit event I've set 

$.mobile.allowCrossDomainPages = true;
$.support.cors = true; 

I suspect there is something between Cordova 3.2.0 and jQuery.
Any help is appreciated.

Pier Alberto
0
Pier Alberto
Top achievements
Rank 1
answered on 14 Dec 2013, 12:15 AM
I tried to go deeper into this issue.
I tested the sample-translator app, which uses cordova 3.2. The same ajax call failing in my app, in the sample app works perfectly. Same permissions, same config.xml and same android.manifest as my app.
The only difference is that my app uses jquery mobile 1.3.2, while the sample app uses 1.3.1. I suppose this can't be the reason of the issue because $.ajax is define in the jquery library (1.9.1 for both apps).

Pier Alberto Guidotti
0
Pier Alberto
Top achievements
Rank 1
answered on 14 Dec 2013, 12:39 AM
I finally solved the problem. I had to change the Android config.xml by replacing:

<access origin=".*"/>

(which I suppose to be the default setting) with:

<access origin="*"/>

It does make sense, I don't understand why it was working well with the previous setting.
0
Marco
Top achievements
Rank 1
answered on 14 Dec 2013, 01:13 PM
Thanks Pier Alberto, your solution works also for me. 
Now ajax post works with cordova 3.2 and icenium
0
Steve
Telerik team
answered on 14 Dec 2013, 02:02 PM
Hi guys,

It appears Pier is absolutely correct and the culprit is in a change Cordova did in v.3.1, namely Unify Whitelist Implemenations. If you create a brand new Icenium app and do not modify the config.xml, the .apk would be build with the new Cordova implementation, but if you edit the config.xml, we would add an outdated configuration file that still uses the old convention.

In short as Pier listed, for existing apps that have their config.xml file edited, make sure that the following line is changed:
from: <access origin=".*"/>

to: <access origin="*"/>

We would make the necessary changes on our end, so this problem does not surface in subsequent versions.

Sorry for omitting this Cordova change guys (which btw is not listed as breaking)!

Regards,
Steve
Telerik
You've missed the Icenium Visual Studio Integration keynote? It has been recorded and posted here.
Looking for tips & tricks directly from the Icenium team? Check out our blog!
Share feedback and vote for features on our Feedback Portal.
Tags
AppBuilder Windows client
Asked by
Marco
Top achievements
Rank 1
Answers by
Pier Alberto
Top achievements
Rank 1
Marco
Top achievements
Rank 1
Steve
Telerik team
Share this question
or