daily pastebin goal
8%
SHARE
TWEET

Untitled

a guest Dec 9th, 2018 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $(document).ready(function() {
  2.     FunctionName();
  3. });
  4.    
  5. $(document).ready(function() {
  6.     FunctionName1();
  7. });
  8. $(document).ready(function() {
  9.     FunctionName2();
  10. });
  11. $(document).ready(function() {
  12.     FunctionName3();
  13. });
  14.    
  15. _spBodyOnLoadFunctionNames.push("Init");
  16.  
  17. function Init() {
  18.     Func1().done(function() {
  19.         Func2().done(function() {
  20.             Func3().done(function() {
  21.                 // All three functions with asynchronous calls now completed in order successfully
  22.             });
  23.         });
  24.     });
  25. }
  26.  
  27. function Func1() {
  28.     var dfd = $.Deferred();
  29.     $.ajax({
  30.         url: //url,
  31.         type: "GET",
  32.         headers: {
  33.             "accept": "application/json;odata=verbose",
  34.         },
  35.         success: function (data) {
  36.             // Do something with data if you want to
  37.             dfd.resolve();
  38.         },
  39.         error: function (data) {
  40.             // Do something with data if you want to
  41.             dfd.reject();
  42.         }
  43.     });
  44.     return dfd;
  45. }
  46.  
  47. function Func2() {
  48.     // Exactly as Func 1
  49. }
  50.  
  51. function Func3() {
  52.     // Exactly as Func1
  53. }
  54.    
  55. function Init() {
  56.     $.when(Func1(), Func2()).done(function() {
  57.         Func3();
  58.     });
  59. }
  60.    
  61. function Init() {
  62.     Func1();
  63.     Func2();
  64.     Func3();
  65. }
  66.    
  67. SP.SOD.executeFunc('sp.js', 'SP.ClientContext', readyFunction);
  68.  
  69. function readyFunction() {
  70.     Function1();
  71.     Function2();
  72.     Function3();
  73. }
  74.    
  75. $(function(){
  76. function1();
  77. function2();
  78. function3();
  79. });
  80.    
  81. $(function(){
  82. ...
  83. });
  84.    
  85. $(function(){
  86. function1();
  87. });
  88.  
  89. $(function(){
  90. function2();
  91. {);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top