Reputation: 17
I have a JavaScript abc.js that is running on a div (class one) element. The script is working fine on elements located within the div element in the html code, but it's not working on data returned from success ajax call that appended to id=tow element.
Here is the code;
HTML
<script type="text/javascript" src="abc.js"></script>
<div class="one">
<ul id="tow">
<li>
<a href="images.jpg">
<img src="images/a1.jpg"/>
<span>
<div class="title"><img src="Images/a2.jpg" /></div>
</span>
</a>
</li>
</div>
JavaScript
$(document).ready(function () {
$('#search').click(function () {
if (cid != 0) {
$.ajax({
type: "POST",
url: 'ajax.php',
data: {
aid: aid,
cid: cid,
sid: sid
},
success: function (data) {
$("#tow").html(data);
}
});
}
});
});
The data returned from success ajax is:
<li> <a href="images3.jpg"><img src="images/a4.jpg"/>
<span>
<div class="title"><img src="Images/a5.jpg" /></div>
</span>
</a>
</li>
Upvotes: 1
Views: 1721
Reputation: 28154
success: function(jqXHR)
{
$("#tow").html(jqXHR.responseText);
}
jQuery ajax returns a jqXHR object. What you are interested in is its responseText property.
Upvotes: 2