调用Web服务后无法从我的jquery移动应用中检索服务器时间 [英] Cannot retrieve server time from my jquery mobile app after calling a web service

查看:81
本文介绍了调用Web服务后无法从我的jquery移动应用中检索服务器时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想问一个有关此问题的一般性问题,因为我不知道在代码或应用程序中哪里可以找到我的问题.我有一个J Query移动应用程序,该应用程序的页面通过在SQL中调用getDate来检索数据库服务器时间.在Visual Studio中开发的C#Web服务中传递了用于检索此时间的sql执行,该服务将JSON字符串返回前端.要使用C#调用Web服务,Java脚本对包含Web服务的给定URL有一个j Query $ .post命令.如果我在google chrome firefox浏览器中运行我的应用,一切都很好.移动应用页面检索正确的时间和正确的日期.如果我在电话"或我的平板电脑"测试中查看了相同的内容,则所获得的信息就是几天前或几小时前在浏览器中检索到的信息.我知道这些信息可能太笼统了,但是没有人对我应该在哪里解决此特定问题有任何指导.

I wanted to ask a general question regarding this issue because I do not know where I can find my issue in my code or app. I have a J Query mobile application that has a page retrieving the database server time by calling getDate in SQL. The sql execution to retrieve this time is passed in a C# web service developed in Visual Studio that returns a JSON string back tot he front end. To call the web service in C# the java script has a j Query $.post command to the given url containing the web service. If I run my app in a google chrome firefox browser everything is fine. The mobile app page retrieves the correct time and correct date. If I view this same content on a testing I Phone or I Pad the information I get is information I would have retrieved a few days ago or a few hours ago on my browser. I know this information may be too general but does anyone have a direction on where I should be looking at this specific issue.

谢谢.

推荐答案

Safari的缓存功能非常强大.您可以在POST中添加时间戳,以通过为每个调用生成唯一的调用来克服此问题.

Safari can be very aggressive with its caching. You can add a timestamp to your POST to overcome this by generating a unique invocation for each call.

 $.post("/MyService/", { timestamp: new Date().getTime() }, ...)

这篇关于调用Web服务后无法从我的jquery移动应用中检索服务器时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆