I have a php page that I am calling via ajax and the returned value i want to place in the page as a new element. For example I have
<div id="main">
<div class="element">
Old stuff
....
</div>
<div class="element">
....
</div>
<div class="element">
....
</div>
</div>
This is my page
I have a php page I am calling view Jquery ajax that returns this structure
<div id="main">
<div class="element">
New stuff
....
</div>
<div class="element">
....
</div>
<div class="element">
....
</div>
</div>
So i need to hide the old stuff and replace it with the new block
JQuery ajax actually has a shortcut for that, if you want to replace the contents of your “main” div: