How to create Ajax Enabled Webservice in .Net 2.0
function Likes_Count() {
debugger;
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "http://localhost:1157/WebSite2/likes/likesservice.asmx/LikesCount",
data: "{ 'Cat': '" + cat + "','title': '" + title + "'}",
dataType: "json",
success: function (data) {
$("#likes_count").html(data.d);
},
error: function (result) {
alert("Error");
}
});
}
window.onload = Likes_Count;
webservice code
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.Services;
using System.Web.Script.Services;
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ScriptService]
public class LikesService : System.Web.Services.WebService {
public LikesService () {
}
[WebMethod]
public string AddLikes(string cat, string title)
{
return cat;
}
[WebMethod]
public string[] Likes_Count()
{
string[] arr4 = new string[1];
arr4[0] = "Success";
return arr4;
}
[WebMethod]
public string LikesCount(string Cat, string title)
{
return "98948";
}
}
System.Web.Script.Services namespace is not found in .net 2.0. but found in 3.5 and 4.0
this code works well in 3.5 and 4.0
so please tell the alternate way to create ajax enabled webservice in .net 2.0