This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript" src="http://code.jquery.com/jquery.js"></script> | |
<script> | |
$(function () { | |
$("#delete").click(function () { | |
var ctx = SP.ClientContext.get_current(); | |
var web = ctx.get_web(); | |
var list = web.get_lists().getByTitle("MyList"); | |
var listItem = list.getItemById("1"); | |
listItem.deleteObject(); | |
ctx.executeQueryAsync( | |
Function.createDelegate(this, onDeleteSuccess), | |
Function.createDelegate(this, onFail)); | |
}); | |
function onDeleteSuccess(sender, args) { | |
alert('Success'); | |
} | |
function onFail(sender, args) { | |
alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace()); | |
} | |
}); | |
</script> | |
<input id="delete" value="Delete" type="button" /> |