为什么我不能通过Ajax调用获得价值?

时间:2011-10-20 04:37:39

标签: php javascript jquery ajax cakephp

我创建了一个这样的Ajax函数:

function searchPlanAjax(url){ 

        jQuery('#loader').css('display','block');
        var plan = jQuery('.rad').val();
        var site = url+"fbilling_details/subscription";
        jQuery.ajax({
               type: "POST",
               url: site,
               data: "plan="+plan,
               //data: "business_name="+val+"&bs="+bs,
               success: function(msg){

                   jQuery('#loader').css('display','none');
               }
           });
    }

我正在打电话给单选按钮onclick:

<?php echo $form->text(BILLING_DETAIL.'][id_plan', array('type'=>'radio', 'value'=>$val[PLAN]['id'], 'id'=>'id_plan_'.$val[PLAN]['id'], 'class'=>'rad','onclick'=>'searchPlanAjax('."'".SITE_NAME.ROOT_FOLDER_NAME."'".')')); ?>

Ajax调用将在cakePHP的控制器中处理,如下所示:

if(!empty($_REQUEST['plan'])){
            $search_plan = $this->{PLAN}->find("all",array("conditions"=>array("id=".$_REQUEST['plan'])));

            $this->set('search_plan',$search_plan);
        }

但我无法在$ search_plan变量中获得价值。谢谢,如果有人可以提供帮助。

1 个答案:

答案 0 :(得分:0)

查看查找查询中的条件

if(!empty($_REQUEST['plan'])){
        $search_plan = $this->{PLAN}->find("all",array("conditions"=>array("id" => $_REQUEST['plan'])));

        $this->set('search_plan',$search_plan);
    }