Is it really Ajax what I am looking for ? Can you check this code? |
[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?
[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.
[eluser]ytsejam[/eluser]
Code: $("#sidebar-content ul li a").click( function(e){ I have written this one but still no success.
[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.
[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?
[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...onpopstate https://github.com/balupton/history.js https://github.com/balupton/history.js/w...e-Handling http://stackoverflow.com/questions/39570...ry-is-best |
Welcome Guest, Not a member yet? Register Sign In |