Advertisement
Guest User

Untitled

a guest
Apr 20th, 2014
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. function1();
  2. function2();
  3.  
  4. Please look at the code written below:
  5.  
  6. function1() {
  7. $.ajax({
  8. url: myurl,
  9. type: 'GET',
  10. async:false,
  11. success: function(response) {
  12. function2();
  13. }
  14. });
  15. }
  16.  
  17. function1() {
  18. ...
  19. $.ajax({
  20. url: '...',
  21. type: 'GET',
  22. success: function(data) {
  23. // this will be executed after the asynchronous method finishes
  24. function2();
  25. }
  26. });
  27. }
  28.  
  29. function function1()
  30. {
  31. //Ajax Call
  32. ..
  33. ..
  34.  
  35. if (xmlhttp.readyState==4 && xmlhttp.status==200)
  36. {
  37. function2();
  38. }
  39. }
  40.  
  41. function1() {
  42. $.ajax({
  43. url: myurl,
  44. type: 'GET',
  45. success: function(response) {
  46. function2();
  47. }
  48. });
  49. }
  50.  
  51. function1(function() {
  52.  
  53. function2();
  54.  
  55. });
  56.  
  57. function function1() {
  58. $.ajax({
  59. url: "url",
  60. type: 'POST',
  61. }).success(function (html) {
  62. function2();
  63. });
  64. }
  65.  
  66. function ajaxCall(){
  67. return $.get('your/api/call', {param:1});
  68. }
  69.  
  70. function fun1(){
  71. console.log('Function 1 was called');
  72. }
  73.  
  74. function fun2(){
  75. console.log('Function 2 was called');
  76. }
  77.  
  78.  
  79. ajaxCall().done(fun1).done(fun2);
  80.  
  81. $.when( $.get('your/api/call') )
  82. .then(function(){ alert(1); })
  83. .then(function(){ alert(2); });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement