Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 12th, 2012  |  syntax: None  |  size: 0.43 KB  |  hits: 13  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. jQuery Deferreds - Pass result of $.when to $.then
  2. function ajaxfn(data) {
  3. prevalidate(data);
  4. return $.ajax(settings);
  5. }
  6. $.when(ajaxfn).then(function() {
  7. // put 'xyz' on the page somewhere.
  8. });
  9.        
  10. $.when(ajaxfn()).then(function(data) {
  11.     // put 'xyz' on the page somewhere.
  12. });
  13.        
  14. function ajaxfn(data) {
  15.     prevalidate(data);
  16.     return $.ajax(settings);
  17. }
  18.  
  19. ajaxfn().then(function(response) {
  20.     console.debug(response);
  21. });