Click here to Skip to main content
15,568,965 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi
i am trying to call webmethod from masterpage using JQUERY AJAX.but the method not executed please help.

see the code below

$.ajax(
               { //call the Page method using JQuery ajax
                   type: "POST",
                   url:  "DefaultMaster.master/UpdatePollCount",
                   data: data,
                   contentType: "application/json; charset=utf-8",
                   dataType: "json",
                   success: function (msg)  //show the result
                   {

                       $("#divPoll").css("cursor", "default"); //remove the wait cursor
                       $("#btnSubmit").attr("disabled", "false") //enable the Vote button

                       $("div[id$=divAnswers]").fadeOut("fast").html(msg.d).fadeIn("fast", function () { animateResults(); });
                   }
               });
Posted
Comments
thatraja 20-Nov-11 3:59am    
Mention the error message, check it in browser javascript debugger

1 solution

I am not very sure if JQuery-Ajax will work with Url of Master-Page.

You may try below things.

1) Check you have specified WebMethod attribute on your UpdatePollCount Method. Someting as below.
C#
[System.Web.Services.WebMethod]
public static string UpdatePollCount(string Data)
{

}


2) I have used "ICallbackEventHandler" for Ajax call on Matser-Page before. You may have a look at below link for "ICallbackEventHandler" use. In this Tip/Trick I have shown example of .Aspx page but it also works for Master-Page.

Simplifying Asp.Net Core Ajax
 
Share this answer
 
Comments
[no name] 9-Mar-15 8:36am    
Its not working on MasterPage.Can u have solution for that..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900