我正在使用JavaScript使用SharePoint RESTful API。當使用_spPageContextInfo它不起作用。如何在sharepoint中使用_spPageContextInfo應用程序
錯誤:未捕獲的ReferenceError:_spPageContextInfo沒有定義
這裏是我的代碼使用
<html xmlns="http://www.w3.org/1999/xhtml">
<script src="../Scripts/jquery-1.8.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$.getJSON(_spPageContextInfo.webServerRelativeUrl + "/_api/web/currentuser",
function (data) {
$("#message").text('hello' + data.d.Title);
});
});
</script>
...
您是否缺少實際具有_spPageContextInfo的必要元素?看看[這篇文章](http://sharepoint.stackexchange.com/questions/116359/bare-minimum-page-to-get-sppagecontextinfo-loaded)。 –