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

  • Home
  • SEARCH
  • 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 8086517
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T18:28:53+00:00 2026-06-05T18:28:53+00:00

Facts I have an mvc project. I am using jquery. The problem $(‘#ModalData’).empty(); is

  • 0

Facts

  • I have an mvc project.
  • I am using jquery.

The problem

$(‘#ModalData’).empty(); is not working as I expected.

Details

When I click on the test link three times I get
enter image description here

However, the hello world was supposed to be emptied by
$(‘#ModalData’).empty();
but it doesnt. Instead everytime I click on test link it open the modal dialog and creates a new hello world.

Also note that If I append the html without using partial view then jquery empty works. Any help?

 $(".modal").on("click", function () {

        $.ajaxSetup({

        cache: false
    });
    $("#dialog-form").dialog("open");

    $('#ModalData').empty();//not working to well

    $.get("/MedicineManagement/GetModal/", function (data)
    { $("#ModalAjaxData").append(data); });
});


$("#dialog-form").dialog({
    autoOpen: false,
    height: 400,
    width: 550,
    modal: true,
    buttons: {
        "Modify Actual Potential": function () {


            if (true) {
                $(this).dialog("close");

            }
        },
        Cancel: function () {
            $(this).dialog("close");

        }
    },
    close: function () {


    }
});

Controller

     [HttpGet]
        public PartialViewResult GetModal()
        {
            return PartialView("_AddMedicineList");
        }

HTML that triggers jquery

 <div id="dialog-form" title="Edit Actual Potential">
        <div class="ModalAjaxData" id="ModalAjaxData"></div>
    </div>
    <a href="#" class ="modal">test </a>
  • 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-05T18:28:55+00:00Added an answer on June 5, 2026 at 6:28 pm

    In your AJAX success callback you are appending:

    $("#ModalAjaxData").append(data);
    

    instead of setting the html of the #ModalAjaxData div:

    $("#ModalAjaxData").html(data);
    

    Also you seem to be emptying some #ModalData element which I cannot see anywhere in your markup so it is not surprising that $('#ModalData').empty(); does nothing. You probably meant $('#ModalAjaxData').empty();. But if you use $("#ModalAjaxData").html(data); instead of appending you don’t need to be emptying anything.

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

Sidebar

Related Questions

I'm currently working on an Intranet application project, using ASP.NET MVC 3. One of
I have an ASP.NET MVC 3 view using Razor and Knockout.js that is not
I have created a website using ASP.NET MVC and use ELMAH for error handling,
In my current project, we have to create a website (ASP.NET MVC) which is
I have a MVC 3 project that uses Entity Framework. I can successfully update
I have a form in an ASP.NET MVC project which has a select drop
I have a couple of probably related issues. Firstly in my ASP.NET MVC project
I have several projects written in f/x4.0 that are not MVC. No web involved.
I have an MVC 2.0 application that requires a persistent login(if chosen) using forms
I've been working on an ASP.NET MVC project for about 8 months now. For

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.