replacing something else after ajax request?
i have this html:
<a href="#" class="cancel" id="cancel_3'">cancel</a>
when the user clicks cancel, i want to remove the hyperlink and i want to replace this with an image i.e.
$.ajax({
context:this,
type: "POST",
url: "actions/cancel.php",
data: "id开发者_StackOverflow中文版=" + the_id,
cache: false,
success: function() {
$(this).remove;
// add image
thanks :))
Try:
success: function() {
$( "a#cancel_3" ).replaceWith( "<img...>" );
}
You'll have to fill in the HTML in the replaceWith function with whatever you want to replace the link with. is just a placeholder I used.
How about:
$(this).css('display', 'none').after('<img>');
精彩评论