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 8010503
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T18:45:16+00:00 2026-06-04T18:45:16+00:00

A long explanation but I believe this is a pretty simple question. I think

  • 0

A long explanation but I believe this is a pretty simple question. I think I’m missing something here.

After selecting a user role from a dropdown menu I’m loading a partial view with users for that role into a DIV with ajax:

        $.ajax({
        type: 'post',
        data: { id: roleId},
        url: '@Url.Action("Manage","User")',
        success: function (data) {
            $("#user-manage").html(data);
        }
    });

Now, on the page I have a combobox with the list of users and a Delete button.
I highlight a user, press the Delete button and user gets deleted.

Great! It works ,however my problem is that the deleted user doesn’t disappear from the Combobox list until the page is refreshed. And I can’t refresh the page because that’d mean that web site user would have to start over with selecting the Role.

So, the question is how can I make the user disappear on the combobox as soon as I hit that delete button ?

Right now when the delete button is pressed the selected UserId is passed the following ajax call that deletes a selected user and returns the updated JSON user list:

    function removeUser() {
    var selectedUser = $("#user-combo").find(":selected").val(); //grab selected user
    var selectedForRole = $("#role-id").val(); //hidden field to store selected role

    $.ajax({
        url:"/User/Delete", //Delete selected user and return updated Json list
        data: { id: selectedUser , roleId: selectedForRole },
        type: 'post',
        success: function (data) {
            var userList = $("#user-combo");
            var listContent;

            $.each(data, function (index, item) {
                listContent += "<option value='" + item.Id + "'>" + item.Name + "</option>";
            });

            userList.html(listContent);
        }
    });
}    

Functionally this works. The user gets deleted but I don’t see it reflected on the $(“#user-combo”) box until I refresh the screen.

location.reload(); doesn’t work for me as I don’t want the web site user to go through selecting a role to see the updated list of users.

How can I make this interactive and users disappear when I delete them and appear when add them later on ?

Thank you in advance.

Edit.
Json object returned to the combobox:

return Json(roleUsers.Select(x => new
            {
                Id = x.Id,
                Name = x.Name
            }));
  • 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-06-04T18:45:18+00:00Added an answer on June 4, 2026 at 6:45 pm

    It is as simple as this:

    $("#comboBox option[value='USER-NAME']").remove();
    

    Put this in your removeUser(). function.

    In fact the function must not olny remve the user from the remote list, but also from the DOM.
    Hpe this help.

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

Sidebar

Related Questions

I've pondered this for a long time, but I've never heard an explanation. I'm
Bit of a long explanation below, with a hopefully accurate short question summary here:
Quick question that requires a long explanation.. Say I have two tables - one
This question might seem very specific but I am in need of some ideas
I feel like there's something rather basic I'm missing here, which I previously thought
EDIT 2: After writing up an incredibly long explanation in more detail I, of
Short Question: What's the best date format to use in SQL Server? Long Explanation:
I wish to settle my long term problem by this question and hope you
I know it might sound like an odd question, but theres a logical explanation
A long title but hard to compress it without losing explanation. Image explanation: http://img560.imageshack.us/f/skrmavbild20110321kl135.png/

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.