![]() |
help with simple ajax - 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: help with simple ajax (/showthread.php?tid=36102) |
help with simple ajax - El Forum - 11-21-2010 [eluser]Unknown[/eluser] Hi there, I'm new to ajax and don't know the first thing about it, but I need to use it on my site. I watched this tutorial on Nettuts+ and got a lot from it, but it still isn't enough for me to get ajax, since in my case, it doesn't work. The main functionality of my site is recording that a person attended a lecture. I display this data in a view and the data is displayed in a table from which I want to get the person id, and the lecture id. If I click on a link inside a tablecell which represents the arrival of a person X on a lecture Y, I want AJAX to register that in the database. If I do this manually (using phpmyadmin) it works great, but I need AJAX. I have a model called administration which has two functions. One of them (get_arrivals) is for retrieving data from a table which works great, but the other one, related to AJAX is causing me problems. Code: <?php The controller I use is called arrivals Code: <?php My jQuery function to get the person_id and lecture_id is this Code: $(function() The problem is when I run this in the browser, and click on a link inside a tablecell nothing happens (no database action, no AJAX action). I know I'm doing something wrong but I can't figure out what. Please give me a hand with this. help with simple ajax - El Forum - 11-21-2010 [eluser]smilie[/eluser] Hm... in your jQuery you query for success: ... but your function is not returning anything :S Try: Controller: Code: if ($this->input->post('person')) And in model: Code: function save_arrival($data) I would also recommend that you also catch errors in live script ![]() Cheers, Smilie help with simple ajax - El Forum - 11-21-2010 [eluser]CroNiX[/eluser] I believe Code: data: { person: person_id, lecture: lecture_id, arived: yes}, Code: data: { person: student_id, lecture: lecture_id, arived: "yes"}, You never defined a "person_id", but you did define "student_id" but you never used it. "yes" is a string and should be in quotes. Nothing to do with the functionality of the code, but "arived" is spelled "arrived". Also, where is "window_location" that you are using for the ajax call defined in your javascript? |