我有一個應用程序頁面(CSS)部署在MS SharePoint 2010的頁方法調用從jQuery的到SharePoint
的_LAYOUTS
文件夾,我想打電話給標有使用jQuery的[WebMethod]
屬性,該屬性頁面中的方法。我在document.ready()
上使用以下代碼:
$("#btnOk").click(function() {
var theUrl = '/_layouts/MyProject/MyPage.aspx/MyMethod';
$.ajax({
type: "get",
dataType: "json",
url: theUrl,
data: {},
success: function (response) {
[...]
},
error: function (xhr, textStatus, errorThrown) {
[...]
}
});
});
此代碼很不幸不起作用。問題出在網址上:實際上,如果我使用這樣的絕對URL,它就會起作用
var theUrl = 'http://server/sites/xxx/_layouts/MyProject/MyPage.aspx/MyMethod';
如何在絕對路徑中轉換我的路徑?
[PageMethods vs UpdatePanels](http://izlooite.blogspot.com/2010/06/pagemethods-vs-updatepanels.html) – 2011-05-23 06:33:17