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

[eluser]taewoo[/eluser]
ok.. so I

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

Code:
http://localhost/index.php/rpc.php?j=2&q=id21&t=127.0.0.1&c=10

and this is the result I got

Code:
unit_longid21|

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

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

[eluser]wiredesignz[/eluser]
Well that proves the ratings_rpc is working properly. So the issue is probably javascript.
#23

[eluser]taewoo[/eluser]
Thanks Wiredesignz...
Is this a JS include issue? I'm pretty lost on this one..
#24

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

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

[eluser]wiredesignz[/eluser]
Try this welcome_view, I have added site_url() to the css and javascript sources, make sure the url_helper is loaded.
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
&lt;html lang="en" xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"&gt;
&lt;head&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;
&lt;/head&gt;
&lt;body&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>

</div>

&lt;/body&gt;
&lt;/html&gt;
#26

[eluser]taewoo[/eluser]
Ah-ha!
I got it..

in function sndReq rating.js, i changed this line
Code:
xmlhttp.open('get', 'rpc.php?j='+vote+'&q;='+id_num+'&t;='+ip_num+'&c;='+units);
to
Code:
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!
#27

[eluser]wiredesignz[/eluser]
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
#28

[eluser]taewoo[/eluser]
wiredesignz:

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

Code:
http://localhost/index.php/listing/view/100/rpc.php?j=4&q=100&t=127.0.0.1&c=5&r=1

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:

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

[eluser]wiredesignz[/eluser]
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.
#30

[eluser]Unknown[/eluser]
Hello,

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