【发布时间】:2011-12-02 02:22:59
【问题描述】:
我使用了一个由Henrik Nyh 巧妙编写的 Jquery 截断器解决方案,具有读取更多/更少的功能。脚本here
我想修改此代码,以便能够通过更新数据库来跟踪已读/未读状态。我编写了在 Web 服务中更新数据库的代码,如下所示。
[WebMethod]
public void updateReadStatus(int ID)
{
//code to update the database
}
我添加了以下内容以使用 Jquery 中的 web 服务
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 unknown”错误,我认为问题出在行数据中:
"{'ID': " + $("#lblID").Text + "}",
如何从标签的文本值中获取参数 ID 的值以将其传递给 Web 服务?
【问题讨论】:
标签: c# jquery asp.net web-services