ajax - How to load plain text in to div from another page -
i'm trying load content page div page div.
what i've got:
jquery:
$('#news_date-1').load('test.php .news_date-1'); test.php
<div class="news_date-1">20-11-2009</div> destination.html
<div id="news_date-1"></div> the result =
<div id="news_date-1"><div class="news_date-1">20-11-2009</div></div> the result want =
<div id="news_date-1">20-11-2009</div> can out?
you can try calling unwrap() on in callback.
$('#news_date-1').load('test.php .news_date-1', function () { $(this) //will refer #news_date-1 .find('.news_date-1') //find inserted div inside .contents() //find contents .unwrap(); //unwrap contents, removing unneeded div }); this not beautiful solution, because .load() inserts dom, , tamper dom again, should minimized.
another way see using $.get() instead:
$.get('test.php', function(receivedhtml) { //getting parts need var neededhtml = $(receivedhtml).find('.news_date-1').html(); //adding dom $('#news_date-1').append(neededhtml); });
Comments
Post a Comment