I am developing a web app using Javascript client side with Jquery Library and PHP server side. I made extensive use of AJAX and I'm not using any href
attribute on link elements. Only the home page is loaded from zero. The others are requested by AJAX calls and the AJAX responses are put into the home page, for example using the Jquery .html()
function, to display new pages.
The problem is when I run http://sani.com/index.php
, I get the home page. If I click on search button, I get the http://sani.com/search
page. But if I run http://sani.com/search
on the address bar, I get only the AJAX response so the content to put inside the homepage and not the whole http://sani.com/search
page.
How can I get the complete http://sani.com/search
page when I run this url on the address bar? What am I doing wrong?
Keep it simple. Just add another route that will return search html. For example:
/search - will return your whole rendered search page. /getSearchHtml - will return your only html snippet you need.
It will help you to avoid confusion in your routes.