2

My project is SharePoint-Hosted Add-in and i want to verify if script sp.js is loadded before run my code in App.js file.

When i use

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

I have load this js files:

  <!-- Required references to use the JSOM from a SharePoint-hosted html page -->
    <script type="text/javascript" src="//ajax.aspnetcdn.com/ajax/4.0/1/MicrosoftAjax.js"></script>
    <script type="text/javascript" src="../_layouts/15/sp.runtime.js"></script>
    <script type="text/javascript" src="../_layouts/15/sp.js"></script>
    <script type="text/javascript" src="../_layouts/15/sp.ui.controls.js"></script>

When i insert SP.SOD.executeFunc worked, bu pageload, refreshed two times...

Error is: enter image description here

Tommorow when i uses Promise.then or .done in this post error is the same :

jQuery.Deferred exception: Unable to get property 'then' of undefined or null reference TypeError

3

Make sure you have below js files loaded in exact sequence.

<script src="/_layouts/1033/init.js" type="text/javascript"></script>
<script src="/_layouts/MicrosoftAjax.js" type="text/javascript"></script>
<script src="/_layouts/sp.core.js" type="text/javascript"></script>
<script src="/_layouts/sp.runtime.js" type="text/javascript"></script>
<script src="/_layouts/sp.js" type="text/javascript"></script>
  • see my updated question, i doest have sp.core.js and init.js – Goshky Dec 31 '16 at 12:58
  • <script src="../_layouts/15/init.js" type="text/javascript"></script> pageLoad func reloaded 2 times, 2 times says : "pageLoad is loadded" in my picture – Goshky Dec 31 '16 at 13:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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