Software Archive
Read-only legacy content
17061 Discussions

Cross Domain AJAX call in New Android Build is not working

Amar_Deep_S_
Novice
2,194 Views

Hi If we are using the Android build or the ANdroid crosswalk build the cross domain ajax calls using the jquery are not working , while those calls work if we choose the legacy build. The calls works fine in the app previews , only on the real device it fails. Please let me know if you have any work around or fix for this. 

FYI server is sending the data with correct headers and i have enable the access mode to * in the XDK.

 

Regards

Amar 

0 Kudos
1 Solution
Amar_Deep_S_
Novice
2,194 Views

Just Now i updated my cordova CLI version to 3.5 and then it works fine for me , So below is the setting for me, which worked  fine for the me.

domain list have below values *, http:\\*, https:\\* , my server allowing the cross domain calls by sending the cross domain header. 

below is the jquery code

$.ajax({
        "method": "POST",
        "url": MY_SERVER_URL,
        dataType: 'json',
        crossDomain: true,
          error: function (jqXHR, textStatus, errorThrown) {
            alert('new textStatus=' + textStatus + ' errorThrown=' + errorThrown);
        },
        success: function (response) {
}
});

Thanks Swati for your kind support and efforts. 

Regards

Amar 

View solution in original post

0 Kudos
15 Replies
Swati_S_Intel1
Employee
2,194 Views

Hello Amar,

Please send your .apk and the entire project zip, I'll have a look at it and see what's wrong. 

Did you start your project with HTML5+Cordova project type?

Thanks,

Swati

 

0 Kudos
Nikko_M_
Beginner
2,194 Views

Hi Swati,

This is also the case for me. I've been trying to compile and build my project yesterday and AJAX calls are not working.

Me and Amar have the same case. I could also send to you my .apk if you want.

Regards,

Nikko

0 Kudos
Swati_S_Intel1
Employee
2,194 Views

Amar's app worked on my android 4.4.2 device. I debugged the app, it might be that it's failing on Android 5.0. Are you also using Android 5.0? Also, please try using Cordova CLI 3.5 instead of 4.1.2 and see if that works for you.

Thanks,

Swati

0 Kudos
Nikko_M_
Beginner
2,194 Views

Hi Swati,

My app still doesn't work on real devices. But it works great on the emulator and debug tab. I am testing on Android 4.1.2 device and 4.4.2 and I'm getting the same results on both devices.

All $.ajax calls return Status of 0.

I also changed CLI version to 3.5 and still the same. Any build I do it doesn't work.

I'm new to IntelXDK, and your help is very much appreciated. I'm already stuck here for 2 days figuring this thing out.

Thank you!

Regards,

Nikko

 

0 Kudos
Swati_S_Intel1
Employee
2,194 Views

Hello Nikko,

Did you put * in the Domain List box under build settings on Projects page?

Please send me your project zip as well.

Swati

0 Kudos
Swati_S_Intel1
Employee
2,194 Views

Please try importing this attached sample ajax app, build it and let me know if it works on your devices.

Swati

0 Kudos
Amar_Deep_S_
Novice
2,194 Views

Hi Swati,, 

I am tried the app on the Samsung Galaxy S4 android v 4.4.2 , kernel v. 3.4.0-1125940, baseband version  I337UCUFNC1, but it still doesn't work , I deleted the project and created a new hybrid project with same source code, but still the call is failing , i have domain as * , http:\\* , https:\\* in my project configuration , but still same issue exists.

 

Regards

Amar

0 Kudos
Amar_Deep_S_
Novice
2,194 Views

Hi Swati,

The sample ajax application which you sent , is also having the same problem , in emulator it runs fine , but on real device it failed with same error not found. :)

I tried to build my code with adobe phone gap build service , In that build it works fine on real device , but admob  plugin stopped working. i tried to build your ajax project using the legacy build, it works in that build. So it looks like there is some bug in the new build, or we are missing something. Please let us know if you find some solution , I believe you are using the dell venue device for your testing, please try with some other device as well.

Regards

Amar

 

0 Kudos
Nikko_M_
Beginner
2,194 Views

Hi Swati,

The sample app did not work for me same as Amar.

I'll send you my zip including the .apk of both the sample ajax test and my app.

Thanks,

Nikko

 

EDIT --

@Swati - I did include my website url in the whitelist and I also tried putting * to allow all website but still it doesn't work.

0 Kudos
Amar_Deep_S_
Novice
2,195 Views

Just Now i updated my cordova CLI version to 3.5 and then it works fine for me , So below is the setting for me, which worked  fine for the me.

domain list have below values *, http:\\*, https:\\* , my server allowing the cross domain calls by sending the cross domain header. 

below is the jquery code

$.ajax({
        "method": "POST",
        "url": MY_SERVER_URL,
        dataType: 'json',
        crossDomain: true,
          error: function (jqXHR, textStatus, errorThrown) {
            alert('new textStatus=' + textStatus + ' errorThrown=' + errorThrown);
        },
        success: function (response) {
}
});

Thanks Swati for your kind support and efforts. 

Regards

Amar 

0 Kudos
Nikko_M_
Beginner
2,194 Views

Hmmm.. Strange and weird but awesome!

I tried what Amar did and it worked for me.

Thank you also to Swati for the CLI 3.5 tip.

Now it's working. I can now continue in developing this app.

Thank you so much for your support.

Regards,

Nikko

0 Kudos
Swati_S_Intel1
Employee
2,194 Views

I'm glad with Cordova CLI 3.5, ajax calls worked for you. I've reported this issue. Until we have a resolution please continue to use CLI 3.5.

Thanks,

Swati

0 Kudos
Bhavya_A_
Beginner
2,194 Views

Hi Swati,

My app is still not able to consume the web service which is another domain i have made all the changes in my project .Please help me out with it.

thanks

Bhavya Anand

0 Kudos
Xochitl_E_
Beginner
2,194 Views

Hi everybody
I have the same problem, but in this case now phonegap doesn't work with CLI 3.5, I try with the ajax but i dont have response,

Any idea? Can you help me?

Thanks

Xoch

0 Kudos
Reply