By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,567 Members | 1,670 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,567 IT Pros & Developers. It's quick & easy.

how to return value from ajax function?

P: 7
i want to return value from ajax function to the function where ajax call has been made.
Expand|Select|Wrap|Line Numbers
  1. function val()
  2. {
  3. var temp=ajaxfun();//ajax function;
  4. }
  5.  
  6. function ajaxfun()
  7. {
  8. //url,type, data will go here and then
  9. success: function(somedata){
  10. //here i want to return data i.e. somedata
  11. //something like "return somedata" to val();
  12. }
  13. }
  14.  
Mar 29 '13 #1
Share this Question
Share on Google+
1 Reply


Dormilich
Expert Mod 5K+
P: 8,639
it doesn’t work like that with asynchronous AJAX calls.

you could of course use a synchronous call, but the you wouldn’t need a success callback function either.
Mar 29 '13 #2

Post your reply

Sign in to post your reply or Sign up for a free account.