javascript - Jquery ajax running twice -


so, have problem. using plugin named jrating, esentially rating system in jquery. problem is, onclick, ajax request fires twice.

after searching lot, tried things:

  1. i checked , double checked $(document).ready(function(){} , jquery shortcut $(function() {}); not twice in page.
  2. i checked id of call unique.

so, here code:

jquery:

$("#rating").jrating({             step:true,             length : 5,             canrateagain : true,             nbrates : 3,             onclick : function(element,rate) {                  var data = (rate, 1);                 $.ajax({                     url: 'application/index/rate',                     type: 'post',                     datatype: 'x-www-form-urlencoded',                     async:false,                     contenttype: 'application/x-www-form-urlencoded',                     data: rate,                     success: function () {                         console.log('submit works');                      },                      error: function () {                         console.log('there error while submit');                      }                  });                }         }); 

phtml:

<div id="rating" data-average="<?=$average //note working everytime!?>" data-id="1"></div> 

thanks inputs!

edit: jsfiddle: http://jsfiddle.net/je79u/ ;

to recreate problem, click run, go console/network, clear contents, click anywhere on yellow/orange bar, rate, , see happens. again time!

with reference of http://demos.myjqueryplugins.com/jrating/ , jrating work ajax. so, takes ajax running twice

please check demo website clearly.

in once rate update records http://demos.myjqueryplugins.com/jrating/php/jrating.php

and use following version of jrating https://github.com/alpixel/jrating


Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -