简体   繁体   中英

Second ajax call not working in Phonegap Jquery mobile Windows phone 8

I'm building a phonegap application using Jquery mobile, I use ajax calls for communicating with tomcat server. All my scripts are located within the application. My first ajax call works and my second ajax call does not work for Windows Phone 8 and it works in Android and iOS.

I'm using single domain and also I've used cross domain flags just in case still no luck with second ajax call. I have ajax calls in each of the JQM page, only the ajax call which is in the login page work and all other ajax calls doesn't work though I get (HTTP 200 OK )as response, I do not see the request in Tomcat log in the server (though I can see first login ajax request).

I think that the jsession ID created during initial ajax call (login) gets lost in some way during navigation to next JQM page.

This is the ajax call I'm using in my application,

request = $.ajax({
url: "http://X.X.X.X/Servlet/Login",
type: “post”,
data: serializedData
});

I have the following flags in the app, though I'm not using a cross domain (all calls are made to same IP).

 $(document).bind("mobileinit", function() {
                $.support.cors=true;
                $.mobile.allowCrossDomainPages = true;
                $.mobile.pushStateEnabled = false;
                $.mobile.touchOverflowEnabled = false;
                $.mobile.defaultPageTransition = 'slide';
                $.mobile.defaultDialogTransition = 'pop';
                $.mobile.transitionFallbacks.slide = 'none';
                $.mobile.transitionFallbacks.pop = 'none';
                $.mobile.buttonMarkup.hoverDelay = 0;
                $.mobile.phonegapNavigationEnabled = true;
            });

I have set data-ajax=“false” in the forms I use.

Also I had to remove event.preventDefault(); for Windows Phone 8 other wise after submit button is clicked the page refresh's with no action being done.

I want to state again that, my code works perfect in Android and iOS (with just cross domain flag added). But in Windows Phone 8, I'm unable to make second ajax call to the same server.

I hope I can fix the issue with your help, any lead will be much appreciated. thanks.

this is likely related to a cache issue - to try and solve this, please try adding a miscellaneous random value in your serialized data. You can reference this

Prevent browser caching of jQuery AJAX call result

i had a similar issue with an ajax call and this random variable solved the problem

I had to enable cookies from internet explorer of Windows Phone 8 to fix my issue. Hope this helps to solve someone's frustration.

i had the same issue. i disable the cache and fix the issue:

request = $.ajax({ url: "http://X.X.X.X/Servlet/Login",
                   type: 'post',
                   data: serializedData,
                   cache: false
                 });

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM