简体   繁体   English

第二个ajax调用在Phonegap Jquery移动Windows Phone 8中不起作用

[英]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. 我正在使用Jquery mobile构建一个phonegap应用程序,我使用ajax调用来与tomcat服务器进行通信。 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. 我的第一个ajax调用有效,而我的第二个ajax调用不适用于Windows Phone 8,并且可以在Android和iOS中使用。

I'm using single domain and also I've used cross domain flags just in case still no luck with second ajax call. 我使用的是单域,也使用跨域标志,以防第二个ajax调用仍然不走运。 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). 我在每个JQM页面中都有ajax调用,尽管我得到了(HTTP 200 OK)作为响应,但只有登录页面中的ajax调用有效,而所有其他ajax调用均无法正常工作,我在Tomcat中看不到请求登录服务器(尽管我可以看到第一个登录ajax请求)。

I think that the jsession ID created during initial ajax call (login) gets lost in some way during navigation to next JQM page. 我认为,在初始ajax调用(登录)期间创建的jsession ID在导航到下一个JQM页面期间会以某种方式丢失。

This is the ajax call I'm using in my application, 这是我在应用程序中使用的ajax调用,

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). 尽管我没有使用跨域(所有呼叫均使用相同的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. 我在使用的表单中设置了data-ajax=“false”

Also I had to remove event.preventDefault(); 我也必须删除event.preventDefault(); for Windows Phone 8 other wise after submit button is clicked the page refresh's with no action being done. 对于Windows Phone 8,否则单击“提交”按钮后,页面刷新将不执行任何操作。

I want to state again that, my code works perfect in Android and iOS (with just cross domain flag added). 我想再次声明一下,我的代码在Android和iOS上运行完美(仅添加了跨域标志)。 But in Windows Phone 8, I'm unable to make second ajax call to the same server. 但是在Windows Phone 8中,我无法对同一服务器进行第二次ajax调用。

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 防止浏览器缓存jQuery AJAX调用结果

i had a similar issue with an ajax call and this random variable solved the problem 我在ajax调用中遇到了类似的问题,这个随机变量解决了问题

I had to enable cookies from internet explorer of Windows Phone 8 to fix my issue. 我必须启用Windows Phone 8的Internet Explorer的Cookie才能解决我的问题。 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
                 });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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