Reputation: 561
In the past I noticed that in many sites when you type a link with different arguments something else happens ( ex Google ). I would like to implement that into my site but I don't know how. I would like to do it for the search function to be exact. Let's say my site is test.com. The link test.com/find+item would search the site for the "find item" term. I'm using JQuery and JSON for the site. Also the search box is the 'input#suggestBox'
element and $('input#suggestBox').jsonSuggest(bookData.webSites, {onSelect:callback});
the call for the search.
Upvotes: 0
Views: 132
Reputation: 37075
The technique you are referring to is very closely related to the concept of RESTfulness. nickf's recommendation of using Apache's mod_rewrite is solid, but if you are wanting to really sink your teeth into URL-driven web app methods, I strongly recommend researching REST.
Upvotes: 1
Reputation: 74560
I wouldn't advise using an ajax approach for getting search results on your site.
The reason for this is that if you have someone who wants to take the search results for a particular query on your site, they have no way of actually taking that link and posting it somewhere, and it decreases the possibility of inbound links to your site.
Instead, you should be using a simple form which has a text field but uses a GET action which would then post the values of the form to the query string.
Then, on the server side, you process the request like you would for any other dynamic request to that url.
Of course, how you do that depends completely on the technology you are using on the back end. The point is, this isn't so much about jQuery as it is about properly structuring the URLs on your site to provide functionality as well as discoverability.
Upvotes: 0
Reputation: 546443
Many sites, even this one, use a technique called URL rewriting. It basically takes a URL and rearranges it into a format your scripts can understand.
For example, you might set up a rule so that the URL http://example.com/search/foo
gets rewritten to http://example.com/search.php?query=foo
.
If you are using Apache, there is a module called mod_rewrite
which handles this for you. You can find out more about it on the Apache documentation page or from this excellent question and answer from Owen.
Upvotes: 4