i'm trying to update a listitem using jquery spservices. everything is working but when i try to add a href to a richtextfield it doesnt work. it only updates plain text not the href. below is code, it's just a test so those urls are for testing.
function fn_UpdateListItem(){
$().SPServices({
operation: 'UpdateListItems',
listName: 'Bedrijven',
ID: 1,
valuepairs: [["Software", "<a href='http://www.google.nl'>its a test.</a>"]],
completefunc: function(xData, Status) {
alert('test complete');
}
});
}
if i change the valuepairs to
valuepairs: [[\"Software\", \"test\"]],
it works it puts test in the rich text field. but with href it doesnt work. anyone knows how to fix ? thanks in advane
I got the same problem for Sharepoint 2010, in this case the var dfNotes = CKEDITOR.instances.notes.getData(); didn't work for me, i found this:
https://msdn.microsoft.com/en-us/library/office/ee658527(v=office.14).aspx
var value = SP.Utilities.HttpUtility.htmlEncode(html);
EditTested on Sharepoint 2016 SharePoint On-Premises, It works too, so i it should work for SharePoint Online aswell !!
This is how it worked for me:
function AddListItem(html, list) {
var value = SP.Utilities.HttpUtility.htmlEncode(html);
$().SPServices({
operation: "UpdateListItems",
async: false,
batchCmd: "New",
listName: list,
valuepairs: [["Title", 'Title'], ["Content", value]],
completefunc: function(xData, Status) {
console.log(Status);
}
});
}