Root Cause: You are missing SP.js, some references.
Solution:
Solution:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function () { | |
var hostweburl = decodeURIComponent(getQueryStringParameter("SPHostUrl")); | |
var scriptbase = hostweburl + '/_layouts/15/'; | |
$.getScript(scriptbase + 'SP.Runtime.js', | |
function () { | |
$.getScript(scriptbase + 'SP.js', | |
function () { $.getScript(scriptbase + 'SP.RequestExecutor.js', CallJS); } | |
); | |
} | |
); | |
}); | |
function CallJS() { | |
alert('hi'); | |
} | |
function getQueryStringParameter(param) { | |
var params = document.URL.split("?")[1].split("&"); | |
var strParams = ""; | |
for (var i = 0; i < params.length; i = i + 1) { | |
var singleParam = params[i].split("="); | |
if (singleParam[0] == param) { | |
return singleParam[1]; | |
} | |
} | |
} |