Delete Sharepoint List Item using Javascript

  1. <script type="text/javascript">  
  2. function Delete ()  
  3. {  
  4.   var UpdateNewItemXml= "<Batch OnError='Continue' ListVersion='1'>"   
  5.   
  6.                                                                         + "<Method ID=\"1\" Cmd=\"Delete\">"   
  7.   
  8.                                                                         + "<Field Name='ID'>2</Field>"  
  9.                                                                         + "<Field Name='Name'>Mack</Field>"  
  10.   
  11.                                                                         + "</Method>"   
  12.   
  13.                                                                         + "</Batch>";  
  14.                                                                        FeedbackHTTP = new ActiveXObject("MSXML2.XMLHTTP.3.0");  
  15.                                                                        FeedbackHTTP.Open("POST""http://sp2k10srvr:800/sites/test/_vti_bin/lists.asmx"false);  
  16.                                                                         FeedbackHTTP.setRequestHeader("Content-Type""text/xml; charset=utf-8");  
  17.                                                                       FeedbackHTTP.setRequestHeader("SOAPAction","http://schemas.microsoft.com/sharepoint/soap/UpdateListItems");  
  18.                                                                         var strSOAP = "<?xml version=\"1.0\" encoding=\"utf-8\"?>"   
  19.                                                                  +"<soap:Envelopexmlns:xsi=\"http://www.w3.org/2001/XMLSchemainstance\"xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">"   
  20.   
  21.                                                                         + "<soap:Body>"   
  22.   
  23.                                                                         + "<UpdateListItems xmlns=\"http://schemas.microsoft.com/sharepoint/soap/\">"   
  24.   
  25.                                                                         + "<listName>31stmay</listName>"   
  26.   
  27.                                                                         + "<updates>"+ UpdateNewItemXml + "</updates>"   
  28.   
  29.                                                                         + "</UpdateListItems>"  
  30.   
  31.                                                                         + "</soap:Body>"  
  32.   
  33.                                                                         + "</soap:Envelope>";  
  34.   
  35.    
  36.   
  37.                                                                         FeedbackHTTP.Send(strSOAP);   
  38.   
  39.                                                                         alert("Thank you! your suggestion has been Deleted successfully.");  
  40.   
  41. }