Advertisement
Guest User

Untitled

a guest
Sep 25th, 2016
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. function callback(data) {
  2. return data;
  3. }
  4.  
  5. var xv = jQuery.ajax( {
  6. url: 'http://www.domain.com/json.php',
  7. dataType: 'json',
  8. success: function(data) {
  9. alert('Success.'); // This is alerted.
  10. },
  11. error: function(data) {
  12. alert('File could not be processed.'); // This is not alerted.
  13. },
  14. complete: function(data) {
  15. callback(data);
  16. }
  17. });
  18.  
  19. console.log(callback()); // Getting "undefined" here instead of data.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement