weixin_33743703 2014-06-29 12:24 采纳率: 0%
浏览 19

是什么使isset为null / empty

I have several places that's returning empty and I am not sure why.

One place is using ajax. When an user clicks on the radio button, the value Y or N is sent upon clicking the radio button. When I go to my controller and do echo $_POST['vote']; it is always returning an empty value.

var value = $(this).val();
$.ajax( {
    type: "POST",
    url: url,
    data: {'vote':value},
    success: function(data){
        alert(data);
    }
})

Another place is when i do an ajax upload on a file using a form. On change of the upload field, it always return empty as well. So when I tried isset$_POST[Image] I am always getting a blank. It sees that all my file upload instance is blank.

So what would be the cause of these blanks? I also tried $_GET doesn't help much.

*****[EDIT]*********

<form id="vote-form" action="/some/path?r=shop/vote" method="post">
<input id="ytvote" type="hidden" value="" name="vote[hot_not]">
<span id="vote_hot_not">
<input class="fire-toggle"  value="Y" type="radio" name="Vote[hot_not]" data-radio-fx="Vote[hot_not]" style="display: none;"><a title="   " data-radio-fx="Vote[hot_not]" class="radio-fx" href="#"><span class="radio"></span></a> 

<label style="display:inline" for="Vote_hot_not_0"><img src=" /images/site/red-hot-not.png" id="hot-i"> </label>  
<!--input class… fire-toggle-->
<input class="fire-toggle" value="N" type="radio" name="Vote[hot_not]" data-radio-fx="Vote[hot_not]" style="display: none;"><a data-radio-fx="Vote[hot_not]" class="radio-fx" href="#"><span class="radio"></span></a> <label style="display:inline" for="Vote_hot_not_1"><img src=” /images/site/hot-not.png" id="not-i"></label></span> 
</form>

Now in my fire-toggle I have:

$(".fire-toggle").click(function() {
    var value = $(this).val();
    var url = "<?php echo Yii::app()->createUrl('shop/vote');?>";
    $.ajax( {
          type: "POST",
          url: url,
          data: {'vote':value},
          success: function(data){
              alert(data)
        }
    })
});

So value actually gives me the expected value.. and here in the controller... I simplified everything down to this:

$pid =Yii::app()->request->getQuery('id');
$uid = yii::app()->user->user_id;
$model = PrototypeReview::model()->getUserVote($uid, $pid);//also tried hard code numbers        
$response = $_POST['vote']; //there's nothing in here!
echo $_POST['vote']; 
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 已知平面坐标系(非直角坐标系)内三个点的坐标,反求两坐标轴的夹角
    • ¥15 webots有问题,无响应
    • ¥15 数据量少可以用MK趋势分析吗
    • ¥15 使用VH6501干扰RTR位,CANoe上显示的错误帧不足32个就进入bus off快慢恢复,为什么?
    • ¥15 大智慧怎么编写一个选股程序
    • ¥100 python 调用 cgps 命令获取 实时位置信息
    • ¥15 两台交换机分别是trunk接口和access接口为何无法通信,通信过程是如何?
    • ¥15 C语言使用vscode编码错误
    • ¥15 用KSV5转成本时,如何不生成那笔中间凭证
    • ¥20 ensp怎么配置让PC1和PC2通讯上