Ajax search workaround when JavaScript is disabled?

Up vote 1 down vote favorite share g+ share fb share tw.

I have a search page on my site. The search pulls from a couple (eventually a few) API from external sources. Sometimes a search can take up to 5 seconds.

Because of this, I would like to load my search page at least with a loading gif, and let AJAX begin to pull the data, showing a bit at a time. (similar to gamespot.com although this is a bad example since the search doesn't work with JS disabled) Of course I have to consider the users who have turned Javascript off, so for them I'd just let PHP do the search and they'll have to bear with the wait. What is the best way to implement this?

If I use , then all users still have to wait for the 5 second PHP portion to load anyways. Would I just have the search form send the user to different pages depending on their JS status? Php javascript ajax noscript link|improve this question edited Feb 19 '11 at 21:57 asked Feb 19 '11 at 21:31paul B335 20% accept rate.

If you have the users coming to your page, and then sending the form, that's absolutely the best way to go. E.g. : HTML: .... JavaScript: hookEvent(document.

GetElementById('theForm'), 'submit', function(event) { event.preventDefault(); loadAjaxSearchResults(); return false; }); ...where hookEvent is a function that uses addEventListener or attachEvent (on IE). Off-topic: The hookEvent thing, like a lot of this stuff, is easier if you use a library like jQuery, Prototype, YUI, Closure, or any of several others. For instance, with jQuery: $("#theForm").

Submit(function() { $("#resultsTarget"). Load("ajaxsearch. Php", $(this).serialize()); return false; }).

1 for the first sentence – thejh Feb 19 '11 at 21:46 i've always been under the impression iframes are not ideal. I'll go with the second suggestion. – paul B Feb 19 '11 at 21:55.

Without JavaScript, you will need to post the data to the server and perform a full postback (refresh) on the page. Just like the good ol' days. ;).

Up to an input field. Think of Javascript like an extender. If js is disabled, no autocomplete is extended on the input field.

You may put some text, where you say, dude, turn on js otherwise this will be a long search. And if js is on, hide the text.

Progressive enhancement: Build it so the PHP version works, first and foremost. This is accessible to all. Then, add javascript so that, if available, it performs ajax requests behind the scenes to grab the content and update the current page.

See this book as a simple, great read on the subject: Bullet Proof Ajax.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions