- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
So i came across this problem last week when i was trying to make a small module for a login screen.
I used :
app designer
hybrid app
jquery Mobile
login web service using AJAX -- the code snipet for teh AJAX call is at the very bottom
So, this worked before the February update of XDK. I used to make small modules and then implement them into my photo documenting app for testing. All modules and previous version of my app work fine with the exisitng code i already had. Now that I have updated XDK a lot of things have gone wrong in my app. I had a previous post a few weeks ago about MY app crashing when i logged in on the emulator and had some serious issues. After figuring everything out with XDK staff i ended up recreating my app with a brand new code base using Jquery mobile and the updated XDK. The javascript has pretty much stayed the same with the exception to using document.location.href (because that used ot make it crash).
Everything works fine in the emulator and using the app preview. But yesterday i tried to build my app for APK and iOS and it wont even login. On iOS it gives me this line : alert("failed to load login details");}
So it skips all of my error handling ont he AJAX POST that i gave you below.
When doing research i found that i needed <Script xhr.js > and <script intelXDK.js> and that they are not included in the index.html page. But the post i have read about these issues do not relate to the newest verion of XDK, but instead older versions. So after trying this quick fix i still cannot send my AJAX post as i used to before.
The code snippet at the bottom is literally th elogin script i use and it worked on multiple apps i have made in XDK BEFORE the update. All apps that i have that upgraded with the update still can connect using these AJAX type calls, but if i start a new app from scratch and try to use this is fails. I have attached my full app zip to this post as well. I feel like there is jst something im missing or a small glitch.
Please help me figure this out, ive already completely rebuilt my app to work with the XDK updates because of all the crashing it used to cause and now once again im running into silly problems.
Any thoughts, comments or answers are much appreciated. If i figure out a solution i will post it as well.
Thanks
//LOGIN SCRIPT
function login(){
//console.log("login called");
var email = $("#login_username").val();
var password = $("#login_password").val();
$.ajax({
type: "POST",
url: "http://54.235.248.192/AppwsVTJN/login.php",
data:{
"email":email,
"password":password
},
beforeSend: function () {
// $('.loading').show();
},
complete: function () {
// $('.loading').hide();
},
success: function(status) {
if(status != ""){
localStorage.setItem("IsLoggedIn",1);
localStorage.setItem("LoginEmail",email);
localStorage.setItem("LoginPassword",password);
var new1 = status.split(',');
localStorage.setItem("companyId",new1[0]);
localStorage.setItem("userId",new1[1]);
//console.log(localStorage.getItem("userId",new1[1]));
// intel.xdk.notification.alert("Log in Successfull!", "Login", "Close");
getJobList();
//document.location.href="#viewjobs_online";
////console.log(localStorage.userId);
//location.href = "#mainpage";
}
else{
//console.log("ERROR");
intel.xdk.notification.alert("Log in credentials incorrect!", "Failed", "Close");
// document.getElementById("userid").value= "";
document.getElementById("login_password").value= "";
//$("div.error1");
}
},
error: function(jqXHR, exception) {
if (jqXHR.status === 0) {
alert("Not connect.\n Verify Network.");
} else if (jqXHR.status == 404) {
alert("Requested page not found. [404]");
} else if (jqXHR.status == 500) {
alert("Internal Server Error [500].");
} else if (exception === 'parsererror') {
alert("Requested JSON parse failed.");
} else if (exception === 'timeout') {
alert("Time out error.");
} else if (exception === 'abort') {
alert("Ajax request aborted.");
} else {
//alert("Uncaught Error.\n" + jqXHR.responseText);
alert("failed to load login details");}
$('.loading').hide();
}
});
}
- Tags:
- HTML5
- Intel® XDK
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Brad,
Your app (the .zip you sent previously) worked perfectly fine on android when I built .apk, I'm not sure about iOS, I'll check that as well. But there doesn't seem anything wrong after you make those adjustment for referencing URL in ajax call for emulator. I'll send you the working code.
Swati
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Swati,
The zip that i had given you before a few weeks ago was built using the older version of XDK, and that version of jquery mobile and XDK build worked fine even when i upgraded teh project.
The zip i just sent with this post does not work for android on our end or for iOS. I built it on iOS again today and tried a variety of solutinos and still was not able to get the AJAX post to work for the simple login web service.
On android we are get a 404 error. But i know it has nothing to do with the web service. That exact web service works on other apps and modules i have made.
If you want to recreate the problem you can create a brand new hybrid app, use app designer, use jquery mobile. Make a login page and try to run the web service function login() and just alert the repsonse. It will work on the emulator and the app preview, but if you build it into an APK it will fail. At least it is on my end that is the exact problem.
This wasn't an issue with the previous version of XDK before the February release. The reason its probably not being more of a problem is because apps that were created in the previous version and upgraded continue to work. All apps i have created are with jquery mobile and app designed and all web service are designed with the similar AJAX post, and they return either rows and rows of json or sometimes just html string. Regradless, all of this code that worked before is not working when the app is rebuilt from scratch on the new version of XDK.
The new ZIP i attached is completely redesigned and rewritten using the new XDK version from two days ago. The main different is that im not using document.location.href anymore. The app works perfect for everything in the app preview. But it simply will not login when i built it.
Let me know if you have anymore questions or help recreating the issue. ill continue working on it as well.
Thanks
brad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Oh I see, Let me check the new source code. I'll get back to you.
Swati
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Brad,
The new app JobJacketV3 (2).zip that you created with new version of XDK works fine on Android (APK). I checked the source code also, I don't see any significant difference that could affect the ajax call. Which android device are you testing on? What OS version?
Are you using XDK 1816 or 1826?
Thanks,
Swati
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Swati,
I have an iPhone 6 with updated iOS 8. I also have a samsung note, LG G pad tablet. Also have an extremely old android device. I have updated to 1826.
They all perform the same way. We also have a samsung Note II which is probably are most sophisticated android device and XDK seems to perform differently on that device than the others sometimes, especially with the native camera plugins.
The ZIP i sent you i built and tried to test on all android devices and i get status 404. I also made a new cert, app ID, and provisioning profile today and install an ad hoc version of the app onto my iphone 6. I currently cannot get past the login screen. In the error handling for the AJAX call i have all the status's like 500 error or 404 error but i also have a last resort error if none of those match the error. Im getting the very bottom error on iphone and im getting the 404 error on android.
Im not sure how you couldnt get it to recreate on your side too. I did see another post on page 2 of the app framework forum with a very similar issue trying to make the ajax calls and it not working on the apk build or ios builds. But there was no resolution to that problem.
Im still trying to figure out a solution on my end. Do you have any other suggestions on what we can do to get this working? Or are you still trying to recreate and find a resolution? currently i am trying to find a resolution with the recreated login module rather than the entire JobJacket app i sent you. It still is not allowing AJAX post calls.
Could it be on my php document on the rserver side?
brad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
hmm... strange!
I'm testing on Dell Venue Android 4.4.2, and it works perfectly fine. It goes past the login screen and shows the Jackets page with job listings.
So, your php script is fine. What Android version is your Note II? I'll see if I can test on older android devices.
Meanwhile try running this test program to see if ajax works on your devices.
Swati
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
the page should have job listings with the username and password i gave you. So that means teh ajax call is not working on your phone either
login creditials
username: brad.ike@gmail.com
password: 123456
this should return over 20 rows and build the listview. So the ajax call must not be work, but its not giving you the error either which is strange. The error messages are just html alert("blah blah") , not XDK alerts.
Ill test your helloajax zip
if you have a skype i can instant message with you on their. Mine is brad.ike
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
the ajax call worked with the helloajax call, but there are two significant differences
its not made in the app designer
its not jquery mobile
I have gotten other apps to work without using the app designer which means i dont use jquery mobile either. But the framework makes it easier to use...so i was hopeing i could get it to work with the app designer and jquery mobile framework.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I see, i misread what you wrote, my fault.
android devices have 4.4.2 , iOS is updated to 8
Im still not getting any luck with the iOS ajax call. The biggest issue with this to me is that this never happened in any circumstance before the February release. If the AJAX calls are just not going to work for certain androids and all iOS devices then obviously i will once again have to recreate my app in some other framework, and its primarily due to the February release.
Ill keep trying to find another solution, please let me know if you can find anything to resolve this. Ive been looking at various post on web service issues. Looks like this is becoming a discovered problem for more and more people.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This is strange. I'm trying to figure out what could be wrong.
Can you please write the steps how you created the project (please write all the steps you followed from start)?
And also, I assume you are using Cordova Android build, is that correct?
Thanks,
Swati
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
new project
html5 cordova hybrid app w/ app designer
jquery mobile framework
add the login function to the app.js, successful AJAX call returns an alert("Done")
added the buttons and inputs
renamed the app for the crosswalk build
emulated and worked on emulator
plugins included were the standard cordova plugins that come with a new project
device
splashScreen
1.) built APK for testing -- returened alert "requested page not found [404]
2.) rebuilt the app with ALL cordova plugins checked, no intel xdk plugins..... got the same error again [404]
3.)added xhr.js and intel.js scripts --> returened alert "requested page not found [404]
4.) moved all <script src=""> tags into the <body> rather than in the head. --> returened alert "requested page not found [404]
attached is the ZIP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm going to ask the App Designer engineers to jump in here to see if they can shed some light, this is likely something in App Designer or the versions of jQuery/jQuery Mobile that are causing the problem.
Another thing to try is using Crosswalk to build, not the native Android.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Did anyone ever find anything out about this or a conclusion of any kind? Honestly i had to do work arounds to get anything to work. Basically i have rewritten my apps from previous builds from before the february update tha ti need to use Jquery mobile for.
If i start a new project form scratch with app designer and jquery mobile, nothing will make the AJAX calls i use work. I used an old build of the version of my app(From before the february update) and just rebuilt the new functionality i needed. This was the only way i could get AJAX call to work on the actualy build versions of android and iOS.
If there have been any updates and findings on this i would like to know. Ive had to revert back to using different solutions for app development lately, i would like to be able to use XDK for everything i do, but the updates have made it increasingly difficult as ive had to rewrite and also troubleshoot issues simple becuse i updated my XDK IDE to the latest version.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Brad,
I was able to reproduce the issue. I'm working on it to figure out what's wrong.
Thanks for your patience.
Swati
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Brad,
Finally I found the issue. When you create a fresh project using template, the Domain List is empty (i.e. the appAccess field which is resposible to allow access to other domains, is left blank). This is a bug. There should be "*" in the Domain List box under Build Settings. It tells that your app could access other domains. When it is blank, it does not allow app to access other domains. Please put * in Domain List box and your app should work just fine.
The reason your app worked for me was that when the app is imported the Domain List is not left blank and the ajax calls could go through. So, whenever you import your app, ajax calls will work.
I have filed a bug for this. Sorry for the inconvenience.
Swati
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Okay thanks, I'm going to check and see if this works for my projects. Thanks for all your help. Hopefully these findings will help others! I will let you know what I find when I test this.
Thanks,
Brad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
do i get a new latop or get invited to a conference for pointing out my 2nd bug from this release? Pat on the back to you Swati for resolving it.
=)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I wish we could offer that ;-)
I'm glad I could help. Thanks for bringing up the issues and working with us patiently!
Swati
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
SWATI S. (Intel) wrote:
Hi Brad,
Finally I found the issue. When you create a fresh project using template, the Domain List is empty (i.e. the appAccess field which is resposible to allow access to other domains, is left blank). This is a bug. There should be "*" in the Domain List box under Build Settings. It tells that your app could access other domains. When it is blank, it does not allow app to access other domains. Please put * in Domain List box and your app should work just fine.
The reason your app worked for me was that when the app is imported the Domain List is not left blank and the ajax calls could go through. So, whenever you import your app, ajax calls will work.
I have filed a bug for this. Sorry for the inconvenience.
Swati
Google translation.
Good day!
I'm developing an app with local database with intel XDK 2611, which is assigned via ajax, and after the upgrade of cord 3.5 to 4.1.2 and 5.1.1, the app only works during emulation and also after the preview, after the build work no more ... I added "*" in the whitelist and still not working .... I have no more resources to try to work!
Could someone help me? ...
Thank you already!
![](/skins/images/7FC17B7B85029576C25F1E43CE255B51/responsive_peak/images/icon_anonymous_message.png)
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page