[英]How to pass value to controller?
When I try to pass the url
value to the controller action
, action
is not getting the required value. 当我尝试将
url
值传递给controller action
, action
没有获得所需的值。
I'm sending the value like this: 我正在发送这样的值:
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');
}
and in the controller I have: 在控制器中,我有:
public function ratesongAction()
{
$user=$_POST['rating'];
echo $user;
$post= $this->getRequest()->getPost();
//echo $post;
$ratesongid= $this->_getParam('id');
}
But still not getting the result. 但是仍然没有得到结果。 I am using zend framework.
我正在使用zend框架。
Need alot more information here... How are you calling these functions? 在这里需要更多信息...您如何调用这些函数? Are the values being passed at any stage in the chain?
值是否在链的任何阶段传递? You mention " action ", what are you actually referring to?
您提到“ 动作 ”,您实际上指的是什么?
Further on that - if you mean that the values are not being handled within the PHP section, are you using the correctly named parameters? 进一步的说明-如果您的意思是未在PHP部分中处理值,那么您是否使用正确命名的参数? I see your Javascript code mentioned one parameter called " artist ", but the PHP code mentions " rating " alone.
我看到您的Javascript代码提到了一个称为“ artist ”的参数,但是PHP代码仅提及了“ rating ”。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.