我使用了一個由Henrik Nyh整齊寫入的Jquery truncator解決方案,它具有讀取更多/更少的功能。腳本here在Jquery中使用webservice
我想修改此代碼以便能夠通過更新數據庫來跟蹤讀取/未讀狀態。我按照以下步驟操作web服務中的數據庫更新代碼。
[WebMethod]
public void updateReadStatus(int ID)
{
//code to update the database
}
添加以下消耗Web服務中Jquery的
function updateStatus(){
$.ajax({
type: "POST",
url: "WebServices/myWebService/updateReadStatus",
data: "{'ID': " + $("#lblID").Text + "}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: OnSuccess,
error: OnError
});
function OnSuccess(reuslt) {
alert(result.d);
}
function OnError(result) {
alert(result.status + ' ' + result.status);
}
}
//and i called this function on this line
full_node.find('a:last').click(function() {
truncated_node.show(); updateStatus(); full_node.hide(); return false;
//The user control that im using this scrip on has a repeater that contains a div that contains the paragraph to be truncated.
<div class="readmore">
<%# Eval("Message_Text")%>
<asp:Label ID="lblID" runat="server" visible="false"
</div>
的截斷腳本正常工作,它給了我,我想要的功能,閱讀更多/更少。但是我無法獲得我想要的附加功能。我收到「12030未知」的錯誤,我認爲這個問題是在該行的數據:
"{'ID': " + $("#lblID").Text + "}",
我怎樣才能把參數ID值從拉布勒的文本值將它傳遞給web服務?