I need to call a web method from Ajax call. See the below code which I'm using to make the Ajax call
$.ajax({
type: "POST",
url: '<%= ResolveUrl("WebForm1.aspx/CampaignData") %>',
data: '{"CampName":' + params + '}',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (str) {
// Handle success
alert("Success call");
},
error: function (xhr, textStatus, errorThrown) {
// Handle error
alert("Fails");
}
});
My web method is:
[WebMethod]
public static string CampaignData(string CampName)
{
return CampName;
}