Uncaught ReferenceError: SP is not defined
means the SP.JS
is not loaded properly, to load it Try to format the code as the following :
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script type="text/javascript" src="https://ajax.aspnetcdn.com/ajax/4.0/1/MicrosoftAjax.js"></script>
<script>
$(document).ready(function(){
var scriptbase = "https://<sharepoint online site url>" + "/_layouts/15/";
//Do not change the order, scripts should load by order.
$.getScript(scriptbase + "init.js",
function () {
$.getScript(scriptbase + "SP.Runtime.js",
function () {
$.getScript(scriptbase + "SP.js", execOperation);
});
});
});
function execOperation() {
// **add your code**
context.executeQueryAsync(onSuccess, onFail);
}
function onSuccess() {
}
function onFail(sender, args) {
alert('Error:' + args.get_message());
}
</script>
resetPage
? That can be done by adding asetTimeout(resetPage, 1337)
also and without loading a library for no reason.