How can I convert this "get_cities.php?country='+country" to CI way? - 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: How can I convert this "get_cities.php?country='+country" to CI way? (/showthread.php?tid=26174) |
How can I convert this "get_cities.php?country='+country" to CI way? - El Forum - 01-07-2010 [eluser]shinokada[/eluser] I have the following jquery which has url of get_cities.php?country='+country. I am wondering how I should put this in CI way. Can anyone teach me please? $('#country').attr('value') will be ir or uk etc. And I can change it to 1, 2, 3 etc. Code: function update_cities(){ How can I convert this "get_cities.php?country='+country" to CI way? - El Forum - 01-07-2010 [eluser]Craig A Rodway[/eluser] That depends entirely on your CI application URL/controller structure. How can I convert this "get_cities.php?country='+country" to CI way? - El Forum - 01-07-2010 [eluser]wowdezign[/eluser] I'm not sure I understand your question. Do you want to know how to rewrite the php file that calls? Or are you wanting help with the call itself? How can I convert this "get_cities.php?country='+country" to CI way? - El Forum - 01-08-2010 [eluser]shinokada[/eluser] Ok, I have the following controller and view. Code: class PhpJqueryBook extends Controller views/dynamic_select_boxes.php Code: <?php $this->load->view('inc/header')?> And this produces the following html. Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> This does not work. Can anyone point out what I am doing wrong please? How can I convert this "get_cities.php?country='+country" to CI way? - El Forum - 01-08-2010 [eluser]Aniket[/eluser] i think u are looking for something like.. "base_url_of_site/index.php/controller/get_cities/city_name" while accessing the city name use Code: $this->uri->segment(3); This shud work How can I convert this "get_cities.php?country='+country" to CI way? - El Forum - 01-08-2010 [eluser]Craig A Rodway[/eluser] View: Code: $.get('phpjquerybook/get_cities/'+country, show_cities); Well done - it looks like you have the correct URL there now. Controller: Code: function get_cities(){ Two reasons why you shouldn't be using $_POST. Firstly, in CI, you would use $this->input->post('country');. But secondly, your javscript code is sending a GET request, not a POST request. This modified code should work: Code: function get_cities($country = ''){ How can I convert this "get_cities.php?country='+country" to CI way? - El Forum - 01-08-2010 [eluser]shinokada[/eluser] Thanks. |