Jump to content

Call ajax front controller not working


pippo67

Recommended Posts

Hello,
I created a personal comment form with star ratings. I'm using ajax  to send the form, the comment is inserted in the db, but the value of the evaluation is 0. The problem I believe is in the Tools: getValue ('rating')  method: it does not receive the value of the evaluation.

This is code:

<div class="starrr" id="rating-comment"/></div>

<form action=''>
 <input type="submit" id="submit" value="" /> 
  <textarea  id="comment"  rows="10" cols="50"></textarea>
</form> 

<script  type="text/javascript">
{literal}
var rating;
$('#rating-comment').starrr({    
    change: function(e, value){
        rating = value;
        ...................................................      
}); 
$('#submit').click(function() {        
    var comment = $('#comment').val();                
   $.ajax({                          
           url: baseDIR + 'modules/mymodule/controllers/front/save.php',          
           type: 'POST',                                               
          data: {comment: comment, rating: rating},
           ................... ........ 

    });           
});   
{/literal}
</script>

All this is in a tpl file                          

class MymoduleSaveModuleFrontController extends ModuleFrontController
{    
    public function initContent()
    {                        
        parent::initContent();        
        $rating = (int)Tools::getValue('rating');
        $comment = trim(Tools::getValue('comment'));

thank you.

Link to comment
Share on other sites

  • razaro changed the title to Call ajax front controller not working

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...