0

I am working on a search box. So far, I am able to search and redirect to Google with the correct XML output. However, I don't want to redirect the URL, but show the produced XML where my search box is placed.

Currently, My search box is located on search.php and after clicking search it redirects me to google with XML output. I want to stay on search.php with produced XML.

I researched that Iframe could be useful, but I just want to know the best way to achieve the solution in context of PHP.

Billal Begueradj
  • 20,717
  • 43
  • 112
  • 130
WOW
  • 317
  • 1
  • 3
  • 13
  • Write a little PHP to produce your desired XML output and then AJAX to fetch that result and then insert it into the page. – Brett Harris Mar 23 '17 at 21:13
  • Yes! I was thinking along the same lines. Thanks just wanted to know the best practices! – WOW Mar 23 '17 at 21:15
  • If you want to make life easier on yourself use jQuery instead of pure JS. You're going to want to put a placeholder container on the page to insert the results, make the AJAX request to your PHP script and on the callback replace the innerHTML of the placeholder container with the return of the AJAX call. Check out http://stackoverflow.com/questions/9436534/ajax-tutorial-for-post-and-get – Brett Harris Mar 23 '17 at 21:56
  • Is your search powered by google, that is is your XML search result provided by google? Can you show your code for the search form? – blokeish Mar 23 '17 at 23:47

0 Answers0