I'm getting this error when i'm trying to execute delete code
SCRIPT5007: Unable to get property 'deleteObject' of undefined or null reference
Here is my code...Not sure what is going wrong here.
var context = SP.ClientContext.get_current();
var web = context.get_web();
var oList;
var listitems;
function deletelistItems() {
var oList = web.get_lists().getByTitle('TracingList');
var query = new SP.CamlQuery();
query.set_viewXml("<Where><Contains><FieldRef Name='Recepient' /><Value Type='Text'>Recepient Created!</Value></Contains></Where>");
listitems = oList.getItems(query);
context.load(web);
context.load(listitems);
context.executeQueryAsync(function deleteListItems(){
var listCount = listitems.get_count();
for(var i =listCount; i>=0; i--){
var itemToDel = listitems.itemAt(i);
itemToDel.deleteObject();
} }, function deleteQF(sender, args) {
alert("Request Failed. \nError: " + args.get_message());});}