Click here to Skip to main content
15,897,163 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
on asp.net page i am using the code like this:

JavaScript
$('.del').click(function (event) {
                var parentID = { "CategoryID": $(this).closest('li').attr('id') };
                parentID = JSON.stringify(parentID);

                alert('before ajax calling');
                $.ajax({
                    type: "POST",
                    url: "MasterService.asmx/RemoveCategory",
                    data: parentID,
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    success: function (msg) {
                        alert('hurray! Success. ' + msg.d); $(this).closest('li').remove();
                    },
                    failure: function (response) {
                        alert(response.d);
                    }
                });


            });

and made a web service method as:

C#
[WebMethod]
public string RemoveCategory(string CategoryID)
{
    CategoryMasterBAL categorymasterBAL = new CategoryMasterBAL();

    return categorymasterBAL.RemoveCategory(CategoryID);
}


but when i run this application then before $.ajax({ alert is fired but not fired in success or error and on debugging control not going to C# code
Posted
Updated 14-Aug-13 1:36am
v2
Comments
ZurdoDev 14-Aug-13 7:38am    
.ajax does not have a failure option, it is error. http://api.jquery.com/jQuery.ajax/ Try changing to error and see what error you are getting. It may be a path issue.

Also, in your class declaration of the web service do you have
[System.Web.Script.Services.ScriptService]
Joezer BH 14-Aug-13 7:44am    
:puzzled: the code looks fine at first glance...
recheck the url name, also, try to see the parentID value before the ajax call.

In the Webservice the following line might have been commented out, please un-comment it and it will work.

C#
[System.Web.Script.Services.ScriptService]
 
Share this answer
 
v2
Thanks ryanb31 i forgot to add [System.Web.Script.Services.ScriptService]
now it's working.
 
Share this answer
 

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


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