在javascript if语句中取消设置$\u POST

在javascript if语句中取消设置$\u POST,javascript,php,jquery,ajax,http-post,Javascript,Php,Jquery,Ajax,Http Post,我需要取消设置$\u POST['u'],但仅在javascript函数中,现在$\u POST数组在页面准备就绪后自动取消设置自身 function resetChat(cod_c){ if(confirm('are you sure?')){ if (sendReq.readyState == 4 || sendReq.readyState == 0) { sendReq.open("POST"

我需要取消设置$\u POST['u'],但仅在javascript函数中,现在$\u POST数组在页面准备就绪后自动取消设置自身

function resetChat(cod_c){
            if(confirm('are you sure?')){

                if (sendReq.readyState == 4 || sendReq.readyState == 0) {
                    sendReq.open("POST", 'getChat.php?chat='+cod_c+'&last=' + lastMessage, true);
                    sendReq.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
                    sendReq.onreadystatechange = handleResetChat; 
                    var param = 'action=reset';
                    param += '&user=' + document.getElementById('cod_user').value;
                    sendReq.send(param);
                    document.getElementById('txt_message').value = '';

                }
            <?php  unset($_POST['u']); ?>  // this only 1 time after confirm???
            }                       
        }
function handleResetChat() {
        }   
功能重置聊天(cod_c){
如果(确认('你确定吗?')){
如果(sendReq.readyState==4 | | sendReq.readyState==0){
open(“POST”、'getChat.php?chat='+cod_c+'&last='+lastMessage,true);
setRequestHeader('Content-Type','application/x-www-form-urlencoded');
sendReq.onreadystatechange=handleResetChat;
变量参数='操作=重置';
param+='&user='+document.getElementById('cod_user')。值;
sendReq.send(参数);
document.getElementById('txt_message')。值='';
}
//这只有一次确认后???
}                       
}
函数handleResetChat(){
}   

PHP是服务器端语言,JavaScript是客户端语言:)您需要进一步了解webdev;)

正如@bordeux所指出的,php是服务器端,而javascript是客户端(在大多数情况下),因此您不能期望使用javascript代码逻辑来控制php流