Is it really Ajax what I am looking for ? Can you check this code? - 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: Is it really Ajax what I am looking for ? Can you check this code? (/showthread.php?tid=53706) |
Is it really Ajax what I am looking for ? Can you check this code? - El Forum - 08-04-2012 [eluser]ytsejam[/eluser] Hello , I am a newbie developer. This is the first time I try to use Ajax. When you start the webpage, a loading animation starts and navigation and content part divides into left and right sides. When I click navigation links I only want content part to change. MY_Controller.php: Code: function render_page($view) { About controller Code: public function view($page = 'about') Ajax.js file is inside head part of header.php. But still I need to change url part by the menu selection not the only about.php. Code: $("#sidebar-content ul li a").click( function(){ my menu is Code: <div id="sidebar-content"> How can I make ajax to work with every menu item (home/about)? What is your suggestion about to post partials to content div? Is it really Ajax what I am looking for ? Can you check this code? - El Forum - 08-05-2012 [eluser]LuckyFella73[/eluser] Your javascript could look like this: Code: $("#sidebar-content ul li a").click( function(e){ That way you can load different urls - like set in your anchors. Is it really Ajax what I am looking for ? Can you check this code? - El Forum - 08-05-2012 [eluser]ytsejam[/eluser] Code: $("#sidebar-content ul li a").click( function(e){ I have written this one but still no success. Is it really Ajax what I am looking for ? Can you check this code? - El Forum - 08-05-2012 [eluser]skunkbad[/eluser] Have you thought about what you will do when the site visitor clicks the back button? How about when they want to bookmark one of your "pages"? While ajax definitely serves a purpose in nearly every website, I think you are going to find that your approach to simple site navigation is going to come back to bite you. My opinion is that you should go normal HTTP requests. Is it really Ajax what I am looking for ? Can you check this code? - El Forum - 08-05-2012 [eluser]ytsejam[/eluser] That is why I am trying to ask about it. All I want to is when I click home.php I want to see home. and when I click about.php I want to see about. I want to get all responses from database. I guess The best way is to Json here right? Is it really Ajax what I am looking for ? Can you check this code? - El Forum - 08-05-2012 [eluser]NeoArc[/eluser] Use HTML 5 onpushstate() if you want to develop Single Page Applications using CI. In older browsers every local link should load a complete page, and not an ajax one... (Hi IE 6). You may want to use a template engine for your views. Some references: https://developer.mozilla.org/en-US/docs/DOM/window.onpopstate https://github.com/balupton/history.js https://github.com/balupton/history.js/wiki/Intelligent-State-Handling http://stackoverflow.com/questions/3957000/what-codeigniter-template-library-is-best |