这是因为UpdateListItems
操作需要 HTML转义字符串作为 aa 参数。
以下函数可用于编码 HTML 字符串:
function htmlEncode(value){
//create a in-memory div, set it's inner text(which jQuery automatically encodes)
//then grab the encoded contents back out. The div never exists on the page.
return $('<div/>').text(value).html();
}
来源
固定示例
var itemID = <Your item id goes here>;
var newContent = "<p>Some content goes here</p>";
$().SPServices({
operation: "UpdateListItems",
listName: "Pages",
ID: itemID,
async: false,
valuepairs: [["PublishingPageContent", htmlEncode(newContent)]],
completefunc: function(xData, Status)
{
console.log('Page has been updated');
}
});