how to pass a value to php variable by ajax

前端 未结 4 2067
花落未央
花落未央 2021-01-25 05:40

this is my javascript code :

function  category(row){
    dataparam = \"oper=delete&row=\"+row;
    $.ajax({
        type: \"POST\",
        url: \"multiuplo         


        
4条回答
  •  自闭症患者
    2021-01-25 06:04

    It looks like you have this wrong, $_REQUEST['opers'] it should be $_REQUEST['oper']

    $opers = (isset($_REQUEST['oper']) and $_REQUEST['oper'] != '' ) ? $_REQUEST['oper'] : '';  
    
    if($opers == "delete") {
        $row=$_REQUEST['row'];
        echo $row;
    }
    

    I would also recommend that as you are expecting the values to come via URL you use the appropriate super global which is $_GET. There is a very small chance that a $_COOKIE could screw you over. If you use them and hapen to give it the value of 'oper'.

提交回复
热议问题