Software Archive
Read-only legacy content
17061 Discussions

json Calls stoped working

Miguel_Q_
Beginner
1,097 Views

Hello.

Suddendly  I can't get my json calls to work.. after update .. i dont understand if is the app preview android app? Because thats the only thing that i updated recenlty! Basically, my $.getJSON calls always falls to the fail callback.. They worked before, oh by the way, testing the "webapp" url on chome browser do work. Its just on this app preview mode that is failling. And the json response on the network panel is okay, returns code 200, and the message is a valid json string...

Something really weird. I tried another stable app, and also does not work anymore. Because the sucess callback is not called... 

0 Kudos
33 Replies
PaulF_IntelCorp
Employee
740 Views

Miguel -- I'm assuming you are now using App Preview 2.8.0, which was just updated? I believe this version now honors the whitelist entries in your build settings, so if those are not set correctly it might be what's causing the AJAX problems. Try adding a * in the allow-navigation rule.

0 Kudos
Miguel_Q_
Beginner
740 Views

Paul F. (Intel) wrote:

Miguel -- I'm assuming you are now using App Preview 2.8.0, which was just updated? I believe this version now honors the whitelist entries in your build settings, so if those are not set correctly it might be what's causing the AJAX problems. Try adding a * in the allow-navigation rule.

 

 

Yes, im using 2.8.0  . The whitelist should not be a problem, because the call is made, and i get the response in a valid json format, according to the debug mode network panel. And i have the " * " anyway. All my apps stoped worked. in debug mode. 

however, If i build them, they do work on the device. It's something on the preview app side. 

0 Kudos
PaulF_IntelCorp
Employee
741 Views

Miguel -- can you provide a simplified version of your app that clearly illustrates the problem. It would help me to reproduce the issue and get it in front of the right people. Please ZIP a project that illustrates the issue and attach it to your post using the "File Attachments" link below the edit window and "attach media" button.

0 Kudos
Miguel_Q_
Beginner
741 Views

Yes, you can simple use this line of code... don't know what is wrong...

 

you have to include jQuery v1.8.3 though.

<script>

$( document ).ready(function() {
 $.getJSON("http://api.fcar.hexiss.com/1/translations/getApp",{lang:"pt-pt",user_version:0}).done(function(e){console.log("done");}).fail(function(e){console.log("fail");});
});

</script>

 

 

so.. what happens on the webbrowser works good, and on the build too. but then the preview mode, it outputs on the console, the fail callback.. althought the network says 200 OK. And the preview does display a valid json response.

 

0 Kudos
PaulF_IntelCorp
Employee
741 Views

I'll alert our App Preview engineers to see if they have any insight.
 

0 Kudos
PaulF_IntelCorp
Employee
741 Views

Sorry, no new information at this time. I have informed the engineers of the problem.

0 Kudos
Hamilton_Tenório_da_
Valued Contributor I
741 Views

I don´t know if my issue is the same or not, but I am dealing with an odd issue: after the last XDK update, one app do not use the correct option (sucess) of AJAX command. Even after contact with the webservice and received a correct answer, the command exits by error.

This app works for a lot of time. I just converted to the new version and build. The issue is present on debug and on device (after build).

It is possible that is a XDK issue?

0 Kudos
PaulF_IntelCorp
Employee
741 Views

Hamilton -- if this is showing up on an unchanged project, in a built app, other than the "upgrade" of your project to CLI 5.4.1 (and possibly upgrading some plugins) then I suspect you are having a Cordova framework issue. The whitelist rules have changed. You might want to open a blank template and see what is done for whitelists on a new blank template and see if those settings will help you in our project. Also, try switching between CLI 5.1.1 and CLI 5.4.1 to see if that makes a difference. See this FAQ for a specific list of the Cordova frameworks that are being used in our 5.4.1 and 5.1.1 build system > https://software.intel.com/en-us/xdk/faqs/cordova#cordova-version

0 Kudos
Hamilton_Tenório_da_
Valued Contributor I
741 Views

@Paul> I made a new project, from blank, to test this situation. I´m sending you in private.

In this project, just press the buttom to start a function AJAX. The result is always by ERROR, even with a correct response from the server (you will see the result just after the error message).

This project is using 5.4.1 / CLI 16.

I downgraded to 5.1.1 / CLI 14 and the issue is the same.

0 Kudos
PaulF_IntelCorp
Employee
741 Views

@Hamilton -- when I use your test app in the Emulate tab and in a built app (CLI 5.4.1 and CW16) it works (I changed it to use the console.log rather than alert, but otherwise, no changes). When I run it in the Debug tab I get the results you describe, which is a successful return but with an error. When I look at the response headers I see two differences, which I've highlighted in the image below. The left side was generated by the Debug tab, the right side by the built app running as "debuggable" via USB:

Screen Shot 2016-04-01 at 4.34.43 PM.png

My suspicion is the "via" that is a proxy, which might be confusing the App Preview debug container. Or, it could be the version of jQuery in your app. I did not get time to experiment with a newer version of jQuery. I'll ask engineering about this early next week.

0 Kudos
PaulF_IntelCorp
Employee
741 Views

@Hamilton -- engineering has reproduced the problem (it appears to be a function of the device, some fail and some work) and is working on understanding what is causing this.

0 Kudos
Miguel_Q_
Beginner
741 Views

exactly, this is my issue, the AJAX now always returns the error callback, although the response headers are OK, and valid JSON. 

I remind you, my whitelist is * and everything worked good, using the new CLI! the only thing i upgraded, was the app preview! I Believe that is the issue, the app preview App, because the build version will work fine...

0 Kudos
Hamilton_Tenório_da_
Valued Contributor I
741 Views

@Miguel> for me, even the build is with this issue. My app doesn´t work with this new version.

0 Kudos
PaulF_IntelCorp
Employee
741 Views

@Hamilton -- that's interesting, you are seeing this failure even in a built app? I am only able to reproduce it in the Debug tab. :-( I'll try a few more devices to see if I can reproduce it in a built app, as well.

0 Kudos
Miguel_Q_
Beginner
741 Views

EDIT: "I upgraded to XDK intel build 3088, and now when i install, the app, its returns "app not installed" on android error app installer..." Was the app id, that was default to template.lite .Sorry, ignore this comment.

 

0 Kudos
Hamilton_Tenório_da_
Valued Contributor I
741 Views

@Paul> Yes, but I will test again to confirm.

@Miguel> Are you installing on device? Do you have the same app installed? Maybe the problem is with the certificate. Try to remove and reinstall the new one. I am handle with this issue too with the new XDK version. I am not how to solve this. 

0 Kudos
Miguel_Q_
Beginner
741 Views

Hamilton Tenório da Silva wrote:

@Miguel> for me, even the build is with this issue. My app doesn´t work with this new version.

 

 

Try this simple build i have, and try the debug vs the build.

For me the build works good. the debug does not ( alert error)

See the attached file.

0 Kudos
Hamilton_Tenório_da_
Valued Contributor I
741 Views

@Miguel> Android without Crosswalk? I think it is not a good solution.

If the app works on pure Android, then the issue is with the new version of Cordova embebed on XDK 3088. Is it possible?

0 Kudos
Miguel_Q_
Beginner
741 Views

Well, for me crosswalk is a no-no.. because the app will be large in size! And usually i dont use crosswalk, and i can use css tricks to work good, on my apps, and fast. Even crosswalk on share mode, i doubt about that... 

Still that is not the core of this issue, what i asked is, if for you that worked good in build mode, and failed in debug mode?

0 Kudos
Hamilton_Tenório_da_
Valued Contributor I
633 Views

@Paul> I did a new test. Lets to result:

a) The new app, made only to test: OK when build and running on device Samsung S4 (sorry my last information was wrong).

b) The old app: ajax response always as ERROR (fail). I am trying now to undertand the difference (jquery.js? appframework.js?).

0 Kudos
Reply