我想通过JSOM和REST在另一个网站集中应用主题。 我得到一个404,该文件没有找到。不要紧,如果我选择另一个spcolor或spfont文件。结果仍然是一样的。通过Javascript在SharePoint中applyTheme
我在做什么错?
var applyTheme = {
url: urlToSiteCollection + "/_api/web/applytheme(
colorpaletteurl='/_catalogs/theme/15/palette007.spcolor',
fontschemeurl='_catalogs/theme/15/fontscheme007.spfont',
backgroundimageurl='/piclibrary/th.jpg',
sharegenerated=true)",
type: "POST",
headers: {
"Accept": "application/json;odata=verbose",
"X-RequestDigest": digest
},
contentType: "application/json;odata=vebose",
success: function (applyThemeData) {
alert("Applyat theme");
},
error: function (ex) {
alert(JSON.stringify(ex));
}
};
$.ajax(applyTheme);
而且JSOM代码:
var clientContext = new SP.ClientContext(urlToSiteCollection);
var web = clientContext.get_web();
var colorPaletteUrl = urlToSiteCollection + "/_catalogs/theme/15/palette011.spcolor";
var fontSchemeUrl = urlToSiteCollection + "/_catalogs/theme/15/fontscheme002.spfont";
var backgroundImageUrl = imageUrl;
var shareGenerated = true;
web.applyTheme(colorPaletteUrl, fontSchemeUrl, backgroundImageUrl, shareGenerated);
web.update();
clientContext.executeQueryAsync(onApplyThemeSuccess, OnFailure);
它现在正在运行,瓦迪姆。谢谢! 我不明白为什么ajax函数不会进入成功函数和日志。但是,嘿,它的工作原理是有效的! –