Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 616169
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T18:17:51+00:00 2026-05-13T18:17:51+00:00

I am creating Menu in the master page using JQuery. i am passing the

  • 0

I am creating Menu in the master page using JQuery. i am passing the id of the link to jquery using $.ajax({});

Problem:

Getting failed: Showing error message in AjaxFailed(result) function.

Code:html[JQuery]

$.ajax({
             type: "POST",
            url: "Master.Master.cs/UserStatus",
            contentType: "application/json; charset=utf-8",
            data: "{}",
            dataType: "json",
            success: AjaxSucceeded,
            error: AjaxFailed
        });

function AjaxSucceeded(result) {

        if (result.d.length != 0) {
            for (var i = 0; i < result.d.length; i++) {
                $(result.d[i]).hide();
            }
        }
    }

    function AjaxFailed(result) {
        alert("Error");
    }  

c# Code:Codebehind

private static List<string> xx;
[WebMethod]
    public static List<string> UserStatus()
    {
        return xx;
    }
protected void Page_Load(object sender, EventArgs e)
    {
        xx = new List<string> {"#ll1", "#ll2" };

    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T18:17:52+00:00Added an answer on May 13, 2026 at 6:17 pm

    What the webmethod attribute does is to say that this method should respond to a certain url (a little bit like routing in asp.net mvc). As I don’t use webforms I don’t really know what logic it uses when it decides what url the method should respond to. But my guess is that the url should be something like “Master.cs/UserStatus” (not sure about the .cs extension). And that is of course a relative url, so you can try something like this: <%=ResolveUrl("~/Master.cs/UserStatus")%> (if the masterpage is in your root folder). Then your example should be something like this:

    $.ajax({
            type: "POST",
            url: '<%=ResolveUrl("~/Master.cs/UserStatus")%>',
            contentType: "application/json; charset=utf-8",
            data: "{}",
            dataType: "json",
            success: AjaxSucceeded,
            error: AjaxFailed
        });
    

    Update

    The .cs extension is probably wrong. But I don’t think you should have that in a master page anyway. You should probably have it in a web service or in a .ashx handler or something if you want to use ajax. But with you last comment it seems that you don’t need to use ajax (and if you don’t need that, you shouldn’t). The problem in the code you wrote in the comment is probably that the id is wrong (remember that you need the client id in javascript).

    But I would probably do it something like this:

    <script type="text/javascript">
        var statuses = [];
        <%foreach(var status in UserStatus()) {%>
            statuses.push(<%=status%>);
        <%}%>
    </script>
    

    This will render this javascript in the browser:

    <script type="text/javascript">
        var statuses = [];
    
            statuses.push("#ll1");
            statuses.push("#ll2");
    
    </script>
    

    Then you will have your statuses in the statuses array.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm attempting at creating a menu from a table using the Suckerfish css menu
I'm building a site using ASP.NET MVC with lots of jQuery and AJAX stuff,
I have an MVC masterpage set up which loads a dynamic menu using AJAX
I'm creating a custom master page for a MOSS publishing site. The designers have
I am creating a simple animated menu using .animate() to enlarge the menu item
I am using zend_navigation for creating menu. Which works fine. Now i m looking
I'm creating a custom control in wxWidgets that displays a menu as part of
My record sheet app has a menu option for creating a new, blank record
Someone can explain this error? Error Creating Control - head Object reference not set
I have an asp.net content page which is used inside of a master page

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.