wood burning stoves 2.0*
The moose likes HTML, CSS and JavaScript and the fly likes doubt on AJAX usage: should AJAX usage be avoided for this use case or should it be used? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "doubt on AJAX usage: should AJAX usage be avoided for this use case or should it be used?" Watch "doubt on AJAX usage: should AJAX usage be avoided for this use case or should it be used?" New topic
Author

doubt on AJAX usage: should AJAX usage be avoided for this use case or should it be used?

Monica. Shiralkar
Ranch Hand

Joined: Jul 07, 2012
Posts: 644
I have been learning AJAX and this doubt regarding when to use and when to avoid using AJAX.


AJAX is used for refreshing a portion of page without reloading the whole page. But I see so many websites where AJAX is used in a limited way and avoided in other cases.


Example Use Case:

I have seen search websites where on entering a keyword whole page reloads to give search results. But what is the use of reloading whole page why not search results be displayed while refreshing only a portion of page.Like this there are other cases where AJAX use is avoided.I want to know why not use AJAX for these or there is a reason?

thanks.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61309
    
  66

You'd have to ask the developers of the site.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Monica. Shiralkar
Ranch Hand

Joined: Jul 07, 2012
Posts: 644
You'd have to ask the developers of the site.


Actually I did not wanted to know that why they have not used but what I wanted to know was since they do not use is frequently for such use cases Is there a valid reason why AJAX should be avoided in certain cases like this.?

thanks
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61309
    
  66

Again, you'd have to ask them. How are we to know what factors went into their decision?

But taking a stratospheric view, I can see no reason that Ajax should be avoided for that general functionality. But again, there may be myriad factors of which we are unaware.
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30585
    
154

Maybe it is an old website? Or they are targeting certain types of users?

Can you give a link to an example of such a website? Maybe we can provide a more useful answer.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Monica. Shiralkar
Ranch Hand

Joined: Jul 07, 2012
Posts: 644
Thanks all.

Below is the link:


http://www.socialmention.com/
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30585
    
154

They are refreshing the page from when you enter the keyword to the full results. That is very common because most of the page needs to refresh. AJAX is meant for refreshing just part of the page. Such as autosuggesting the rest of your search string.

Google refreshed the page on search until recently as well. Now they have you type the search at the top of the page.
Monica. Shiralkar
Ranch Hand

Joined: Jul 07, 2012
Posts: 644
"They are refreshing the page from when you enter the keyword to the full results"

By refreshing, I assume it means that they are reloading the page at this time.


"That is very common because most of the page needs to refresh. AJAX is meant for refreshing just part of the page"

I got the point that ajax is for refreshing just part of refresh.If whole page is to be changed it is better to reload instead of refresh. However if whole page also gets refreshed using AJAX without reloading the page is it not better experience for the user?

" Such as autosuggesting the rest of your search string.".

These are common fixed uses of ajax for this there are direct ways as supported by struts etc.I want to know that usage of ajax apart from common uses as auto-suggestion or auto populating.

Thanks



Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30585
    
154

Monica. Shiralkar wrote:"They are refreshing the page from when you enter the keyword to the full results"

By refreshing, I assume it means that they are reloading the page at this time.

Yes. I meant a full page refresh.

Monica. Shiralkar wrote: "That is very common because most of the page needs to refresh. AJAX is meant for refreshing just part of the page"

I got the point that ajax is for refreshing just part of refresh.If whole page is to be changed it is better to reload instead of refresh. However if whole page also gets refreshed using AJAX without reloading the page is it not better experience for the user?

Why would it be a better experience to refresh the whole page using AJAX vs just refreshing the whole page? Gmail does implement their entire app in JavaScript, so it can be done. But for something as simple as reloading one page, I fail to see the benefit.
Monica. Shiralkar
Ranch Hand

Joined: Jul 07, 2012
Posts: 644
Jeanne Boyarsky wrote
Why would it be a better experience to refresh the whole page using AJAX vs just refreshing the whole page? Gmail does implement their entire app in JavaScript, so it can be done. But for something as simple as reloading one page, I fail to see the benefit.


Not refreshing the whole page.I meant refreshing 90% of the page. After search results are displayed the first time, filter buttons would appear. On selecting filter buttons new results will be displayed. So the next screen would be of the same kind with two differences.First that the results would be results of filter condition not orignal search and two the screen would also have the filter buttons.

thanks
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61309
    
  66

It's not all about the visible content. There is a huge difference between "the whole page" and 90% of the visible content. Even 99% of the visual content. Remember, refreshing the whole page also loses any context and starts everything completely from scratch.

So in the case you are talking about, where the majority of the page is results, and only a small portion is form controls that define the result filters, I'd still use Ajax so as not to have restore the context from scratch on each change.
 
GeeCON Prague 2014
 
subject: doubt on AJAX usage: should AJAX usage be avoided for this use case or should it be used?