【问题标题】:unset $_POST inside javascript if statements在 javascript if 语句中取消设置 $_POST
【发布时间】:2016-03-24 23:10:55
【问题描述】:

我需要取消设置 $_POST['u'] 但仅在 javascript 函数内,现在 $_POST ARRAY 在页面准备好后自动取消设置...

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() {
        }   

【问题讨论】:

  • @bordeux 指出 - php 是服务器端,而 javascript 是客户端(大部分),所以你不能指望使用 javascript 代码逻辑来控制 php 流

标签: javascript php jquery ajax http-post


【解决方案1】:

PHP 是服务器端语言,JavaScript 是客户端语言 :) 你需要了解更多关于 webdev 的知识;)

【讨论】:

    猜你喜欢
    • 2013-06-18
    • 1970-01-01
    • 2019-08-03
    • 1970-01-01
    • 2013-01-17
    • 1970-01-01
    • 2016-07-15
    • 2017-03-10
    • 1970-01-01
    相关资源
    最近更新 更多