displaying another html content in div on ajax success
Posted
by
Manish
on Stack Overflow
See other posts from Stack Overflow
or by Manish
Published on 2012-11-21T04:42:10Z
Indexed on
2012/11/21
5:00 UTC
Read the original article
Hit count: 167
gameLike.jsp
<div class="gameLikeStatus">
<a href="likeit" class="likeitlink">likeit</a>
</div>
var dataString = 'elementId='+ '<s:property value="id"/>'+ '&elementType=' + 'games';
$(document).ready(function(){
$('a#likeitlink').bind('click',function(event){
event.preventDefault();
$.ajax({
type: "POST",
url: "likeit",
dataType: "text html",
data: dataString,
success: function() {
$.post('isLiked',dataString, function(data) {
alert(data);//1
$('#gameLikeStatus').html(data);
});
}
});
});
});
in second.jsp
contains a link
<a href="unlikeit" class="Unlikeitlink">likeit</a>
Here I am liking the element and after like it should display
<a href="unlikeit" class="Unlikeitlink">likeit</a>
instead of
<a href="likeit" class="likeitlink">likeit</a>
at
<div class="gameLikeStatus"></div>
in gameLike.jsp
, alert(data);//1
is showing
<a href="unlikeit" class="Unlikeitlink">likeit</a>
this data but
$('#gameLikeStatus').html(data);
showing nothing.
How to resolve this?
© Stack Overflow or respective owner