473,503 Members | 2,166 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

jquery fails to make a div empty

12 New Member
In my asp.net mvc 4 application, i am loading a partial view in current page. The code successfully loads the desired partial view in <div id="PartialContent"></div> on the current page. But, before sending jquery ajax request to the server, i am trying to clear the div. But the div is not clearing. The old content is still there until the new content arrives. Here is my code-

Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2.     $(document).ready(function () {
  3.         $(".mainnav a").click(function (e) {
  4.             e.preventDefault();
  5.             var url = $(this).attr('href');
  6.             if (url != '#') {
  7.                 $('#PartialContent').empty(); //not working 
  8.                 $('#PartialContent').html(''); //not working 
  9.                 $('div#PartialContent').children().remove(); //not working 
  10.                 $.get(url, function (response) {
  11.                     $('#PartialContent').html(response);
  12.                 });
  13.             }
  14.         });
  15.     });
  16. </script>
Any idea to solve it?
Nov 8 '13 #1
1 2972
Exequiel
288 Contributor
put your $('#PartialContent').html(""); inside of your $.get function.
Expand|Select|Wrap|Line Numbers
  1.  $.get(url, function (response) {
  2.    $('#PartialContent').html("");
  3.    $('#PartialContent').html(response);
  4.  });
  5.  
Nov 11 '13 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
1654
by: Emmanuel Thomé | last post by:
This is a comment aside the empty class behavior FAQ. I understand there are a fair number of reasons which make empty classes have non-zero size (except as base classes). If ``class foo'' were...
2
2439
by: Greg | last post by:
I have a datagridview that will not always have all its rows populated with data, but they all need to be visible. Currently, the grid is only showing rows with data. Is there a way to override...
83
4109
by: liketofindoutwhy | last post by:
I am learning more and more Prototype and Script.aculo.us and got the Bungee book... and wonder if I should get some books on jQuery (jQuery in Action, and Learning jQuery) and start learning about...
53
8315
by: souporpower | last post by:
Hello All I am trying to activate a link using Jquery. Here is my code; <html> <head> <script type="text/javascript" src="../../resources/js/ jquery-1.2.6.js"</script> <script...
5
4902
by: jrod11 | last post by:
hi, I found a jquery html table sorting code i have implemented. I am trying to figure out how to edit how many colums there are, but every time i remove code that I think controls how many colums...
0
2812
by: amskape | last post by:
hi Friends, I need to Upload some files in a Listing , by clicking corresponding Upload link, then a popup window will come with Browse option as Shown in attachment File. My actual need is...
1
1833
by: svendok | last post by:
What does one have to do in the code below to allow jQuery to make use of the find() function that I added to the array object (see line #26)? Is there a namespace clash? The code is here...
0
1475
by: bala venkata siva ram kum | last post by:
Hi all, I am working with menu. for that i download(jquery code) in the net. I included that code in my project in Scripts folder. I take an default2.aspx page which was not included with...
3
1233
colinod
by: colinod | last post by:
i have this page with a opacity change on mouseover that when a picture is half under the top navigation and you mouseover it it brings the faded image over the navigation?? ...
0
7093
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7353
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7011
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7468
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5596
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3180
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1521
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
747
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
401
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.