I have the following HTML hyperlink I want to call it in jQuery when it clicked
<a href="#" data-toggle="dropdown" id="notID" class="dropdown-toggle f-s-14">
<i class="fa fa-bell"></i>
<span runat="server" id="notCount" class="label">5</span>
</a>
When i click the hyperlink the following code executed
<script src="assets/plugins/jquery/jquery-1.9.1.js"></script>
<script>
$(document).ready(function () {
$("#notID").click(function () {
var uID = '<%=Session["userID"].ToString() %>'
$.ajax({
url: 'TaskService.asmx/updateNotRead',
data: '{userID: "' + uID + '"}',
type: 'POST',
contentType: 'application/json',
dataType: 'json'
});
return false;
});
});
</script>
And in the webservice file i wrote the following C# code that have the definition for the webmethod that i call from jQuery above.
[WebMethod]
public void updateNotRead(string userID)
{
u.updateNotReadStatus(userID);
}
When i call the web service i got the following message in the browser
System.InvalidOperationException: Missing parameter: userID.
at System.Web.Services.Protocols.ValueCollectionParameterReader.Read(NameValueCollection collection)
at System.Web.Services.Protocols.UrlParameterReader.Read(HttpRequest request)
at System.Web.Services.Protocols.HttpServerProtocol.ReadParameters()
at System.Web.Services.Protocols.WebServiceHandler.CoreProcessRequest()
So how could I give the web method the userID parameter?