![]() |
CJAX Vote System Problem with multiple clicks - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: CJAX Vote System Problem with multiple clicks (/showthread.php?tid=60975) |
CJAX Vote System Problem with multiple clicks - El Forum - 08-17-2014 [eluser]bubx[/eluser] Hi, I wrote a simple voting system, and I have a problem with multiple clicks. When I click Like ("Mocne"), I can then click on Unlike ("Słabe"), and a lot of times. I would like to be able to click only once, in one or the other. I use CJAX flush method, but something here does not work properly. Article view: Code: <?php Controller: Code: <?php CJAX Vote System Problem with multiple clicks - El Forum - 08-17-2014 [eluser]CroNiX[/eluser] I don't know anything about cjax, but you can always disable or remove a link/button via javascript with a click event. CJAX Vote System Problem with multiple clicks - El Forum - 08-17-2014 [eluser]bubx[/eluser] I did so at the beginning, but for me it was not satisfying. I did this using the session. Code: $data = $this->session->userdata($id); CJAX Vote System Problem with multiple clicks - El Forum - 08-17-2014 [eluser]CroNiX[/eluser] I'm not sure what you're wanting then. In you original post you said "I would like to be able to click only once, in one or the other" CJAX Vote System Problem with multiple clicks - El Forum - 08-17-2014 [eluser]bubx[/eluser] I want that after use "Vote Up" or "Vote Down" the article was excluded from voting for that user (session). CJAX Vote System Problem with multiple clicks - El Forum - 08-17-2014 [eluser]CroNiX[/eluser] It might be because you are using sessions (which uses a cookie) while using ajax. There are a number of problems with ajax and sessions in CI. Does it prevent voting if you navigate to a different page on the site after voting and then come back to it and try to vote again? It might work better if you set a flag in the db that the user voted for that already and then check that when the data is submitted before accepting the vote. Sorry, again I don't know anything about cjax. If it were jquery you could just use $(selector).off('click') to remove the click event. CJAX Vote System Problem with multiple clicks - El Forum - 08-17-2014 [eluser]bubx[/eluser] Conceptually, this also must work for unregistered users, only for one session, and it works. For registered users i want to use database. I do not know too well cjax, but at this time it works fine. Anyway, if there are problems with AJAX in CI, i lose tempted to use this framework ![]() |