jquery ajax request is sent BEFORE beforeSend
Posted
by Booosh
on Stack Overflow
See other posts from Stack Overflow
or by Booosh
Published on 2010-03-18T23:05:53Z
Indexed on
2010/03/18
23:11 UTC
Read the original article
Hit count: 711
Hi all, had anyone the same experiences with jquery ajax() and the beforeSend property??? And even better... any advice how to fix this problem ??? THX ;-) Actually what i am doing is reading from the database with an ajax call before i wanna sent the new data to the database via ajax (I deed to get to the last page of all comments). What happens is that beforeSend retrieves the data WITH the data which should be sent afterwards?!?! Any ideas?!?!
$.ajax({
type: 'POST',
url: '_php/ajax.php',
dataType:"json",
async:false,
data:{
action : "addComment",
comment_author : comment_author_val,
comment_content : comment_content_val,
comment_parent_id : comment_parent_id_val,
comment_post_id : "<?=$_REQUEST["ID"]?>"
},
beforeSend: function() {
//WHAT A MESS...
if (typeof commentOpen == "undefined") {
$.get("_php/ajax.php", { action: "getComments", commentPage: '', ID: "<?=$_REQUEST["ID"]?>" },
function(data){
$('#comments > ul').html(data);
return true;
}
);
}
},
© Stack Overflow or respective owner