开发者

Posting fyneworks star rating data

开发者 https://www.devze.com 2023-02-16 16:26 出处:网络
I am implementing a star rating system on a sports website for users to rate events after they have happened. I then stumbled on this post:

I am implementing a star rating system on a sports website for users to rate events after they have happened. I then stumbled on this post: JQuery Star Rating

It appears to be exactly what I am looking for but I am having some trouble getting it to work as wanted.

The examples on the website suggest that I should have the form subm开发者_运维问答it to send the data to be dealt with, however, I would like it to send the data live as the user clicks on the stats. I am also trying to implement multiple instances of the ratings on one page all clickable.

Jquery:

<script type="text/javascript">
$(function(){
    $('.auto-submit-star').rating({
        callback: function(value, link){
            var id = $(this).attr('id');
            $.post('http://mysite.com/ratings', {
                "type":"type", 
                "eid":"eventid", 
                "item": id, 
                "rating": value, 
                "uid":"userid"
            });
        }
    });
});
</script>

Some of my ratings:

organisation<br />
<input name="org" type="radio" class="auto-submit-star" id="org" value="1"/>
<input name="org" type="radio" class="auto-submit-star" id="org"  value="2"/>
<input name="org" type="radio" class="auto-submit-star" id="org"  checked="checked" value="3"/>
<input name="org" type="radio" class="auto-submit-star" id="org"  value="4"/>
<input name="org" type="radio" class="auto-submit-star" id="org"  value="5"/>
<br /><br />

event rating<br />
<input name="event" type="radio" class="auto-submit-star" id="event" value="1"/>
<input name="event" type="radio" class="auto-submit-star" id="event"  value="2"/>
<input name="event" type="radio" class="auto-submit-star" id="event"  checked="checked" value="3"/>
<input name="event" type="radio" class="auto-submit-star" id="event"  value="4"/>
<input name="event" type="radio" class="auto-submit-star" id="event"  value="5"/>
<br /><br />

The jquery succeeds in getting to my php code to handle the input but on adding to the database I am finding that nothing is coming through.

I have firebug installed as well but can find no record of the post (though am not sure I'm looking in the right place).

Any help would be grand, I checked with an alert and value and id are both working as they should within the page.


Ignore me, I am an idiot... the code was not working as I was running the code without a www. while viewing the website with www.

0

精彩评论

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