Hi All,
I am not able to call web service(asmx) from jQuery function.
It is saying "access denied" error while calling web service. It is working in the dev and local machine but I am getting the same error.
Here is my ajax call
$.ajax({
type: "POST",
url: "http://server.com/calculator.asmx/calculus",
data: "{ 'userID': '" + $("#usrid").val() + "','password': '" + $("#password").val() + "' }",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: Success,
error: Error
});
My web service is
[WebService(Namespace = "http://www.company.com/webservices/calculus")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
[System.Web.Script.Services.ScriptService]
public class calculator : System.Web.Services.WebService
{
[WebMethod]
[System.Web.Script.Services.ScriptMethod(UseHttpGet=false, ResponseFormat = System.Web.Script.Services.ResponseFormat.Json)]
public bool calculus(string userName, string password)
{// my code}
The error is in http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js function and the "Access denied" error at e.username?x.open(n,e.url,e.async,e.username,e.password):x.open(n,e.url,e.async);
I have included [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)] with the class as shown in http://forums.asp.net/p/1570168/3935094.aspx and not able to fix the prob. Can any one please help me regarding this.
Thank you