开发者

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.

I'm sending the value like this:

function val开发者_如何转开发ue(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.


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? I see your Javascript code mentioned one parameter called "artist", but the PHP code mentions "rating" alone.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜