Senguttuvan Amaladass Senguttuvan Amaladass - 1 year ago 79
jQuery Question

Ajax call not working with web method

I need call a web method from Ajax call. find the below cade which I'm using
Ajax call

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


My web method is.

public static string CampaignData(string CampName)
return CampName;
need help to sort out this issue.

Answer Source

I am using .Net 4.0 after change the flowing thing it started hitting the web method break point. Inside ~/App_Start/RouteConfig.cs change:

settings.AutoRedirectMode = RedirectMode.Permanent;


settings.AutoRedirectMode = RedirectMode.Off;

(Or just comment the line)

Also if friendly URLs are enabled you need to change

url: "ConsultaPedidos.aspx/GetClients",


url: '<%= ResolveUrl("ConsultaPedidos.aspx/GetClients") %>',

Hope this help somebody else

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download