Computer Science Canada Jquery/Php help |
Author: | nonamedude [ Sun Apr 10, 2011 12:56 pm ] | ||||||
Post subject: | Jquery/Php help | ||||||
Hey guys, I recently started using jquery, and i have come across a problem for the project i am doing. I am trying to imitate the rating system of youtube for my new site. This site is one that has articles So once a user log ins, i want to be able to read the amount of thumbs up./down the user has for a particular article. So far, i have been able to get this to work. But the problem is, I dont know how this would be possible if there are several articles with a unique id for each of them. This is what I have so far The function that changes the image and increments the value
The php script that reads the mysql database
And this is where it is being printed to
|
Author: | nonamedude [ Sun Apr 10, 2011 2:21 pm ] |
Post subject: | Re: Jquery/Php help |
*bump* |
Author: | Tony [ Sun Apr 10, 2011 2:38 pm ] | ||
Post subject: | RE:Jquery/Php help | ||
you can make a get request with arguments passed back to php
make sure to do properly escape any such arguments. |
Author: | nonamedude [ Sun Apr 10, 2011 2:43 pm ] |
Post subject: | Re: Jquery/Php help |
Oh, i see what you mean, but how do I know which id to request, since the id is in php. Is there a way to pass the id from php to the jquery function? |
Author: | Tony [ Sun Apr 10, 2011 2:58 pm ] |
Post subject: | RE:Jquery/Php help |
Presumably you want the id of the current page you are on, right? |
Author: | nonamedude [ Sun Apr 10, 2011 4:28 pm ] |
Post subject: | Re: Jquery/Php help |
Not the id of the page i am on but the id what i clicked, for example, if an image has an id, when i click it, i want that id to be sent to jquery. |
Author: | Tony [ Sun Apr 10, 2011 4:45 pm ] |
Post subject: | RE:Jquery/Php help |
Right. Lets try it this way -- if the image to be clicked was just a regular link, it would still need to know the ID to go to the right page, correct? How would you "send" an id to that link tag? |
Author: | nonamedude [ Sun Apr 10, 2011 4:56 pm ] |
Post subject: | Re: Jquery/Php help |
I am not sure what you meant but, $('#c').html(value); The 'c' above is the id of the div that i am replacing the value in. If there are more than one divs, then the id has to be changed based on what the user selects. So i need to pass the id on to the function, cause right now, I have just written the c manually. |
Author: | Amailer [ Sun Apr 10, 2011 5:08 pm ] | ||||
Post subject: | RE:Jquery/Php help | ||||
Label each <a> tag for which ID you want to get, with a common class and do something like
then do something like:
|
Author: | nonamedude [ Sun Apr 10, 2011 5:17 pm ] |
Post subject: | Re: Jquery/Php help |
ahhhh i see, thanks a lot!!! |