jQuery ajax related issue
I am trying to figure out, whats I am doing wrong in following code:
$(function() {
$(".alert").live('click', function(){
var id = $(this).closest("tr").attr("id")
var info = 'id=' + id;
$.ajax({
type: "POST",
url: "http://localhost/app/ajax.php?act=alert",
data: info,
success: function(Response){
}
});
alert(Response);
$(this).hide();
return false;
});
});
Return开发者_开发问答 false
is not working.
HTML code:
<a href="#" class="alert">Alert</a>
AJAX is by definition asynchronous.
When your $.ajax
call returns the HTTP request will still be getting processed, and therefore Response
will not yet be filled.
Put the alert(Response)
call inside your success
callback to see how it should work.
精彩评论