2011-12-25 90 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位於某處。

這種技術一直是我的救星。

相關問題