如果从客户端使用服务器端功能,如何返回正确的值? [英] How Can I Return The Correct Value If Working With Server Side Functions From Client Side?

查看:63
本文介绍了如果从客户端使用服务器端功能,如何返回正确的值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我只想根据数据库中的数据返回true或false。但我的JavaScript函数总是返回false。



i必须根据从数据库获取的数据返回true或false但在调用服务器端函数之前,我的JavaScript函数返回值和返回后执行服务器端功能,这就是为什么它总是返回false。



请给我解决方案



在此先感谢。

Hi All,

I just want to return true or false on the basis of data in my database. but my JavaScript function always return false.

i have to return true or false on the basis of data fetched from database but before calling the server side function, my JavaScript function return the value and after returning then execute the server side function that's why it always return false.

Please provide me solution

Thanks in advance.

推荐答案

由于您没有发布任何代码,我们只能猜测。听起来您正在使用
Since you did not post any code we can only guess. It sounds like you are using


.ajax()来调用您的Web服务。有一个async属性,您可以设置为false但我相信只有IE支持;但是,这将停止javascript执行,直到从webservice返回。但由于大多数浏览器不支持它,我不建议。



所以,你要做的就是改变代码的工作方式。您的成功函数必须调用一个新函数,然后在您想要的位置选择。您不能使用包含
.ajax() to call your webservice. There is an async property that you can set to false but I believe only IE supports that; however, that will stop the javascript execution until the return from the webservice. But since most browsers do not support it I do not suggest it.

So, what you have to do is change the way your code works. Your success function will have to call a new function that then picks up where you want it to. You can't use the return value of the function that contains your


.ajax()调用的函数的返回值。
.ajax() call.


这篇关于如果从客户端使用服务器端功能,如何返回正确的值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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