0

A function (F1) has the implementation to access a SP list. This function gets executed and successfully accesses the SP List if this function is called in the click event of a button on the form.

However, the same function when called in document.ready() function, does execute but doesn't access the SP List.

Libraries: JSOM with jquery.

1
  • 2
    Post some sample code that will help to debug the issue...
    – Ankur
    Feb 20, 2016 at 8:53

2 Answers 2

1

Probably the SP files are not loaded by the time document.ready is executed. You can try the following by replacing SpJSReadyMain with your function name

$(document).ready(function () {
    SP.SOD.executeFunc('sp.js', 'SP.ClientContext', SpJSReadyMain);
});

Actually, you don't need to wrap it in document ready function as your function will be called only when SP files get loaded but you may want to do that for other reasons. And, in your case executeOrDelayUntilScriptLoaded also will work.

What is difference between executefunc and executeordelayuntilscriptloaded?

0

Try to Check using this function,

   Function PageLoad()
  {

  //your code
   }

And please post your code here.

Not the answer you're looking for? Browse other questions tagged or ask your own question.