Uncaught TypeError: SP.ClientContext is not a constructor

Usually this will happen when the SP.ClientContext Js file was not loaded before it is being used. in other words, a method has been called before the whole sp.js finished to load into the browser memory. you can overcome this issue by delaying your code until the sp.js is loaded by using the following snippet:

ExecuteOrDelayUntilScriptLoaded(YourInitialJsMehtod, “sp.js”)

Please note that you do need to have a reference to the sp.js files before using it in this order.

 <script src=“//ajax.aspnetcdn.com/ajax/4.0/1/MicrosoftAjax.js”></script>

<script src=“/_layouts/15/sp.runtime.js”></script>

<script src=“/_layouts/15/sp.js”></script>

 

Leave a Reply

Your email address will not be published. Required fields are marked *