2011-12-25 89 views
0

我正试图让人们可以在SharePoint 2003中更新列表的应用程序。我有一个应用程序完美工作,但这不起作用。UpdateListItems(成功),但没有效果?为什么?

是否有某些SharePoint调用告诉我为什么它没有更新?完成后,我会获得“成功”-msg。我只有在那里必须填写蚂蚁它是一个文本行。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<title></title> 
<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.4.1.js" type="text/javascript"></script> 
</head> 
<body> 
    <h1></h1><span id="numbersOfRows"></span> 
<div> 
<script type="text/javascript"> 
    $(document).ready(function() { 
    $("#newTaskButton").click(function() { 
     CreateNewItem($("#newTaskTitle").val()); 
    }); 
}); 

function CreateNewItem(Customer) { 
    var batch = 
     "<Batch OnError=\"Continue\"> \ 
      <Method ID=\"1\" Cmd=\"New\"> \ 
        <Field Name=\"Event name\">test</Field> \ 
      </Method> \ 
     </Batch>"; 

    var soapEnv = 
     "<?xml version=\"1.0\" encoding=\"utf-8\"?> \ 
     <soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" \ 
      xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" \ 
      xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"> \ 
      <soap:Body> \ 
      <UpdateListItems xmlns=\"http://schemas.microsoft.com/sharepoint/soap/\"> \ 
       <listName>On the road</listName> \ 
       <updates> \ 
       " + batch + "</updates> \ 
      </UpdateListItems> \ 
      </soap:Body> \ 
     </soap:Envelope>"; 

    $.ajax({ 
     url: "homepage/_vti_bin/lists.asmx", 
     beforeSend: function(xhr) { 
      xhr.setRequestHeader("SOAPAction", 
      "http://schemas.microsoft.com/sharepoint/soap/UpdateListItems"); 
     }, 
     type: "POST", 
     dataType: "xml", 
     data: soapEnv, 
     complete: processResult, 
     contentType: "text/xml; charset=utf-8" 
    }); 
} 
function processResult(xData, status) { 
    document.getElementById("alertMsg").innerHTML = status; 
} 

</script> 

    <p> 
     Task Title: 
     <input id="newTaskTitle" type="text" /> 
     <input id="newTaskButton" type="button" value="Create Task" /> 
    </p> 
    <h1>Alert:</h1><span id="alertMsg"></span> 


</div> 

</body> 

回答

0

将这个地方你的函数的开始。它为jQuery ajax方法设置错误处理状态。不过,我认为你必须升级到更新版本的jQuery才能使用它(请参阅$ .ajax()下的jQuery文档)。

$("#divId").ajaxError(function(event, request, settings, exception) { 
    $(this).append("Error here: " + settings.url + ", exception: " + exception); 
}); 

其中id =“divId”的DIV位于某处。

这种技术一直是我的救星。

相关问题