Search code examples
phpajaxajaxcontroltoolkit

Ajax with in Ajax. Is this possible


I have a php page. This has multiple images which looks like tabs. With in this php page i have a div which will load different PHP pages on click of different images i mentioned before. This is done using Ajax. This much of it works fine with no page reload. This is done to simulate the tab operation without page reload. This much of it is working fine.

But now i need to have a search operation into one of the inner php file. When i use this using Ajax on kepup to do a search operation and display the result in another div with in the inner php, it becomes a php, within php and another php into it. Totally 3 layers php with all loaded using ajax.

I am facing a problem at this stage. The first layer that is the tab operation works fine with AJAX. the next layer of search using ajax also works but reloads the outer php aswell. So it looks as if the tab is clicked instead of the search operation. So now i run into a confusion as if the concept of loading a form by ajax and then having a ajax search within itself to display the result with keyup, would it be right? will this be possible?

So is is that i have done it wrong or it is not possible to have this option? Because when i load the inner php directly with url without ajax, the search works perfectly fine. Is this possible in a simpler way using code igniter. Please let me know your comments on this and also u'r suggessions. I am sure you would have many questions on what i have asked. Please let me know your questions i will try to reply to them. All suggessions appreciated. Thanks in advance.


Solution

  • I think you're confusing AJAX with frame here.

    When using frames, you are loading pages inside parent page, and normal operations in child pages does not affect parent. When using AJAX, think it as inserting content into current page, and whatever content inserted becomes part of the page and whatever action performed there will affect the page, there is no concept as child page in ajax.

    For your problem, as many have mentioned, you must have initiated a post-back (like form submit) when clicking Search, which causes the page to reload.