Welcome Guest, Not a member yet? Register   Sign In
Ajax star rating bar

ok.. so I

1) updated ratings_rpc.php with the one above
2) I tried


and this is the result I got


    * Current rating.
    * 1
    * 2
    * 3
    * 4
    * 5
    * 6
    * 7
    * 8
    * 9
    * 10

id21 Rating: 2.0/10 (1 vote cast)Thanks for voting!

Well that proves the ratings_rpc is working properly. So the issue is probably javascript.

Thanks Wiredesignz...
Is this a JS include issue? I'm pretty lost on this one..

The next thing you can try is comment out the javascript in welcome_view, see if the page updates properly.

&lt;!--script type="text/javascript" language="javascript" src="js/rating.js"></script--&gt;

Try this welcome_view, I have added site_url() to the css and javascript sources, make sure the url_helper is loaded.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
&lt;html lang="en" xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"&gt;
&lt;meta http-equiv="content-type" content="text/html; charset=utf-8"&gt;
&lt;title&gt;Multiple Ajax Star Rating Bars&lt;/title&gt;

&lt;script type="text/javascript" language="javascript" src="&lt;?php echo site_url() ?&gt;js/behavior.js">
&lt;script type="text/javascript" language="javascript" src="&lt;?php echo site_url() ?&gt;js/rating.js">

&lt;link rel="stylesheet" type="text/css" href="&lt;?php echo site_url() ?&gt;css/default.css" /&gt;
&lt;link rel="stylesheet" type="text/css" href="&lt;?php echo site_url() ?&gt;css/rating.css" /&gt;

<div id="container">
<h1>Unobtrusive AJAX Star Rating Bar</h1>

<h2>v 1.2.2, March 18, 2007</h2>
<p>CodeIgniter port by Wiredesignz, 2008-02-14</p>
<br />
&lt;?php echo $this->ratings->bar('id21',''); ?&gt;
&lt;?php echo $this->ratings->bar('id22',''); ?&gt;
&lt;?php echo $this->ratings->bar('id1',''); ?&gt;
&lt;?php echo $this->ratings->bar('2id',5); ?&gt;
&lt;?php echo $this->ratings->bar('3xx',6); ?&gt;
&lt;?php echo $this->ratings->bar('4test',8); ?&gt;
&lt;?php echo $this->ratings->bar('5560'); ?&gt;
&lt;?php echo $this->ratings->bar('66234','','static'); ?&gt;
&lt;?php echo $this->ratings->bar('66334',''); ?&gt;
&lt;?php echo $this->ratings->bar('63334',''); ?&gt;
&lt;?php echo $this->ratings->bar('63335',''); ?&gt;

<br /><br />
<a href="http://www.masugadesign.com/the-lab/scripts/unobtrusive-ajax-star-rating-bar/">(Unobtrusive) AJAX Star Rating Bar Homepage</a>



I got it..

in function sndReq rating.js, i changed this line
xmlhttp.open('get', 'rpc.php?j='+vote+'&q;='+id_num+'&t;='+ip_num+'&c;='+units);
xmlhttp.open('get', '/index.php/rpc.php?j='+vote+'&q;='+id_num+'&t;='+ip_num+'&c;='+units);

And voila! Big Grin

Thanks for all your guidance and help wiredesignz. You're the man.
If you're ever in Silicon Valley, let me know. I'll buy u beer!

My next idea was to add index.php to the javascript OR use .htaccess mod-rewrite and remove index.php.

Glad you got it working Smile


Actually, implementing it is causing some sorta issue i can't seem to resolve.
Will I need to modify anything if I have the URL as such


where listing = controller, view = method, 100 = data ID

Instead of AJAX kicking it, it seems like the browser is actually looking for http://localhost/index.php/listing/view/100/rpc.php

PS: As you recommended I have in route.php:

$route['rpc.php'] = 'ratings_rpc/index';
and in config.php
$config['enable_query_strings'] = TRUE;
$config['directory_trigger']    = 'd';
$config['controller_trigger']   = 'x';   //remove the `c` conflict
$config['function_trigger']     = 'm';

ratings_rpc is a controller itself, you can't use it in that part of your URL.

You should specify the redirect in your config as $config['nojs'] = the controller / function to call when javascript is disabled,

The URL to use in your view is just http://localhost/index.php/rpc.php?... as normal.

Remember the Ajax call is returned to the browser from the ratings_rpc controller, it is not part of your application as such.


Is there a way in which I can display also text/numbers on the image? Example http://www.wiredesignz.co.nz/ci_rating/, then I want to put numbers on each stars. Is that possible?

Theme © iAndrew 2016 - Forum software by © MyBB