aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes Should I use AJAX for displaying Menu click results? 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 "Should I use AJAX for displaying Menu click results?" Watch "Should I use AJAX for displaying Menu click results?" New topic
Author

Should I use AJAX for displaying Menu click results?

Monica. Shiralkar
Ranch Hand

Joined: Jul 07, 2012
Posts: 670
I have a menu which buttons. On click of one item a form opens and on entering keyword results get displayed. On clicking other page another form displays at the same page instead of first and on enterying data results are displayed. I used strategy of keeping these forms in different Divs and then using javascript for showing or hiding a particular Div.
The above is working fine.
But when the results of either of forms are to be displayed on the same page.Then controling hiding and showing of Divs becomes very tedious.Does this functionality I am trying is simple one which can be showing using simply javascript or it required involvement of AJAX?

thanks
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61768
    
  67

If you don't need to fetch new data from the server, you don;t need Ajax.


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

Joined: Jul 07, 2012
Posts: 670
Yes new data from the server is required. This JSP page has 2 different forms(Of which only 1 will be visible at a time: i did this using javascript).On either form submission results would be fetched from server and displayed on same page. The problem I am facing is that location of the menu gets disturbed once the results are displayed for either form.Thanks.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61768
    
  67

That's just a matter of making sure that the HTML structure and CSS for the menu aren't disturbed. Not much to do with Ajax per se.
Monica. Shiralkar
Ranch Hand

Joined: Jul 07, 2012
Posts: 670
Actually to get rid of that I had to show results of the next page instead of same page but would require to find a solution.
Monica. Shiralkar
Ranch Hand

Joined: Jul 07, 2012
Posts: 670
Is my below understanding correct?

Since I need to fetch data from server (My menu item leads to a search where based on keyword it fetches form Database), so it is always better in this case to use AJAX and not refresh whole page.(Why to reload whole page for the search?)

Thanks
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61768
    
  67

I will very rarely reload an entire page if only part of it needs to be updated.
Monica. Shiralkar
Ranch Hand

Joined: Jul 07, 2012
Posts: 670
if only part of it needs to be updated.


Thanks. Suppose there is a Search for keyword where search results would be fetched from the Database? I am new AJAX my understanding is that in this case Search Results should be fetched by an AJAX action. I would go by this approach. Please correct me if I am wrong.

Thanks
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61768
    
  67

That would likely be my approach.
Monica. Shiralkar
Ranch Hand

Joined: Jul 07, 2012
Posts: 670
Thank You.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Should I use AJAX for displaying Menu click results?