[英]How to pass value to controller?
当我尝试将url
值传递给controller action
, action
没有获得所需的值。
我正在发送这样的值:
function value(url,id)
{
alert(url);
document.getElementById('rating').innerHTML=id;
var params = 'artist='+id;
alert(params);
// var newurl='http://localhost/songs_full/public/eslresult/ratesong/userid/1/id/27';
var myAjax = new Ajax.Request(newurl,{method: 'post',parameters:params,onComplete: loadResponse});
//var myAjax = new Ajax.Request(url,{method:'POST',parameters:params,onComplete: load});
//alert(myAjax);
}
function load(http)
{
alert('success');
}
在控制器中,我有:
public function ratesongAction()
{
$user=$_POST['rating'];
echo $user;
$post= $this->getRequest()->getPost();
//echo $post;
$ratesongid= $this->_getParam('id');
}
但是仍然没有得到结果。 我正在使用zend框架。
在这里需要更多信息...您如何调用这些函数? 值是否在链的任何阶段传递? 您提到“ 动作 ”,您实际上指的是什么?
进一步的说明-如果您的意思是未在PHP部分中处理值,那么您是否使用正确命名的参数? 我看到您的Javascript代码提到了一个称为“ artist ”的参数,但是PHP代码仅提及了“ rating ”。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.