Click here to Skip to main content
15,884,298 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.
Posted
Comments
Member 12078709 17-Nov-15 7:20am    
try with jquery document ready.
$( document ).ready(function() {

//add your script code here

});
F-ES Sitecore 17-Nov-15 7:44am    
You are asking what is wrong with your code, but you haven't posted it so how can we know?
Krunal Rohit 17-Nov-15 8:18am    
And we don't have that crystal ball that shows your code, we don't have an access to your machine/screen. Please share your issue related code.

-KR

1 solution

Since you did not post any code we can only guess. It sounds like you are using $.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() call.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900