Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/68.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在Jquery中使用Web服务_C#_Jquery_Asp.net_Web Services - Fatal编程技术网

C# 在Jquery中使用Web服务

C# 在Jquery中使用Web服务,c#,jquery,asp.net,web-services,C#,Jquery,Asp.net,Web Services,我使用了一个Jquery截断器解决方案,该解决方案是由编写的,具有多读/少读功能。剧本 我想修改这段代码,以便能够通过更新数据库来跟踪已读/未读状态。我注意到在Web服务中进行数据库更新的代码如下 [WebMethod] public void updateReadStatus(int ID) { //code to update the database } 我添加了以下内容以使用Jquery中的Web服务 function updateStatus(){

我使用了一个Jquery截断器解决方案,该解决方案是由编写的,具有多读/少读功能。剧本

我想修改这段代码,以便能够通过更新数据库来跟踪已读/未读状态。我注意到在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>
如何从标签的文本值中获取参数ID的值以将其传递给webservice?

是一个函数,而不是属性,因此需要使用
()
调用它:


另外,如果您想通过Ajax调用给定的WebMethod,则需要使用
[ScriptMethod]
属性对其进行修饰。

您不需要说明
lblID
标识了什么,但您应该:

$("#lblID").text()

看到和

"{'ID': " + $("#lblID").text() + "}", 
$("#lblID").text()
$("#lblID").val()