views:

63

answers:

1

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 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.

+1  A: 

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.

Lucanos
my action code ispublic function ratesongAction() { print_r($_POST['artist']); echo $user; $post= $this->getRequest()->getPost(); //echo $post; $ratesongid= $this->_getParam('id'); //$ratesong= $post['artist']; // echo "ratesong".$ratesong; $lyrics = new Model_DbTable_Lyrics(); $result = $lyrics->getLyricsNameOnId($ratesongid); /*json object*/ $jason_result = Zend_Json::encode($result); $this->view->SongDetail = $jason_result; $this->_helper->layout->setLayout('layout');
rajesh
my view is<a href="#" class="undone" rel="1" id="1" onmouseover="javascript:display(1);" onmouseout="javascript:hide1(1);" onClick="value('<?php echo $this->url(array('controller'=>'eslresult','action'=>'ratesong','artist'=>'1'))?> ','1');">star one</a>
rajesh
and js isfunction 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/'; var myAjax = new Ajax.Request(newurl,{method: 'post',parameters:params[0],onComplete: load}); //var myAjax = new Ajax.Request(url,{method:'POST',parameters:params,onComplete: load}); //alert(myAjax); } function load(http) { alert('success'); }
rajesh