not suring what is the reason but web method not firing but juqery shows success messge on click event
<asp:ListView ID="lvCustomers" runat="server">
<ItemTemplate>
<div id="dvhitem">
<asp:Label ID="lblCustomerId" runat="server" Text='<%#Eval("countryid") %>'></asp:Label>
<asp:Label ID="lblName" runat="server" Text='<%#Eval("countryname") %>'></asp:Label>
<asp:LinkButton ID="lnkComparisionList" runat="server">Save</asp:LinkButton>
</div>
<hr />
</ItemTemplate>
</asp:ListView>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">
$(function () {
$('[id*=lnkComparisionList]').on('click', function () {
var item = $(this).closest('[id*=dvhitem]');
var obj = {};
obj.name = $(item).find('[id*=lblCustomerId]').html();
obj.country = $(item).find('[id*=lblName]').html();
$.ajax({
type: "POST",
url: "webmethod_withoutmaster.aspx/Save",
data: JSON.stringify(obj),
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (response) {
alert("success");
},
failure: function (response) {
alert(response.responseText);
},
error: function (response) {
alert(response.responseText);
}
});
return false;
});
});
</script>
[WebMethod]
public static void Save(string name, string country)
{
}