Monday, 21 July 2014

unable to get property 'get_current' of undefined or null reference

Root Cause: You are missing SP.js, some references.
Solution:
$(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];
}
}
}
view raw gistfile1.js hosted with ❤ by GitHub