JQuery $.post() and CI inquiry - 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: JQuery $.post() and CI inquiry (/showthread.php?tid=2579) |
JQuery $.post() and CI inquiry - El Forum - 08-13-2007 [eluser]stevefink[/eluser] Hi all, I have a simple javascript file being loaded externally that has the following code: -- snip -- $(document).ready(function() { $('#pendingUsers').load('index.php/meduser/check_pending_users',false, function() { $('#pendingUsers a').click(function() { $.post('index.php/meduser/pull_user_information', {id: $(this).attr('rel')} ); }); }); setInterval(function() { $('#pendingUsers').load('index.php/meduser/check_pending_users'); }, 300000); // initially hide the main content div until a pending user is clicked. }); -- snip -- My issue here is I'm not sure how with CI to associate the $.post() with the div I want to populate the data back from the server with in a view. My view contains a <div id="main"></div> area where the results should be posted back. My controller looks like this: function pull_user_information() { $id = $this->input->post('id'); $data['query'] = $this->db_users->query('select * from tbl_signups where ID="$id"' ); $this->load->view('default/meduser_useraccordny_view', $data); } I'm trying to populate the rel of the anchor tag into $id and using that to query the database. I can then pass that into the meduser_useraccordny_view, however I'm still not entirely sure how to populate the particular div. Any assistance would be appreciated! JQuery $.post() and CI inquiry - El Forum - 08-13-2007 [eluser]kucerar[/eluser] [quote author="stevefink" date="1187051673"]Hi all, I have a simple javascript file being loaded externally that has the following code: Code: $(document).ready(function() { My issue here is I'm not sure how with CI to associate the $.post() with the div I want to populate the data back from the server with in a view. My view contains a <div id="main"></div> area where the results should be posted back. ...[/quote] Code: $('#pendingUsers').load('index.php/meduser/check_pending_users',false, function() { Wouldn't that callback load the DIV? -R JQuery $.post() and CI inquiry - El Forum - 08-13-2007 [eluser]stevefink[/eluser] Well, I've tried debugging, and in this case: $('#pendingUsers a').click(function() { $.post('index.php/meduser/pull_user_information', {id: $(this).attr('rel')}, function(data) { $('#main').html(data); alert("Data: " + data); } ); }); data appears to be empty. No idea what the problem is though. JQuery $.post() and CI inquiry - El Forum - 08-13-2007 [eluser]座頭市[/eluser] I think you have a quoting problem: single quotes will not parse variables passed to them - the database is looking for the value $id in the ID column, of course, does not exist and thus causing the empty data set. Try reversing the single and double quote. Code: $data[’query’] = $this->db_users->query("SELECT * FROM tbl_signups JQuery $.post() and CI inquiry - El Forum - 08-14-2007 [eluser]stevefink[/eluser] Yes, rather embarrasing that after hours of debugging, that was my problem. I'll be more cautious in the future, thanks again. |