aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes AJAX required or not Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "AJAX required or not" Watch "AJAX required or not" New topic
Author

AJAX required or not

Hirak Dasgupta
Greenhorn

Joined: Nov 29, 2007
Posts: 4
On based of input from user I want to populate a table from database in the same jsp form without submitting that form.

So, only AJAX can solve this problem or there is some solution other than AJAX?

If AJAX is the only solution then pls provide me the steps for doing that through AJAX.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60072
    
  65

Originally posted by Hirak Dasgupta:
then pls provide me ...
Please use real words when posting to the forums. Abbreviations such as "pls" in place of "please" only serve to make your posts more difficult to read and less likely to generate useful responses.

Please read this for more information.

thanks,
bear
JavaRanch sheriff


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60072
    
  65

As this has nothing to do with Struts and more to do with Ajax, it has been moved to a more appropriate forum.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60072
    
  65

If you want to contact the server without submitting the current page, then yes, Ajax is your best bet.

If you are a rank beginner with Ajax, I'd suggest starting with a good tutorial, such as this article.
Hirak Dasgupta
Greenhorn

Joined: Nov 29, 2007
Posts: 4
Thanks Bear
Anubhav Anand
Ranch Hand

Joined: May 18, 2007
Posts: 341

Originally posted by Hirak Dasgupta:
On based of input from user I want to populate a table from database in the same jsp form without submitting that form.

So, only AJAX can solve this problem or there is some solution other than AJAX?

If AJAX is the only solution then pls provide me the steps for doing that through AJAX.


Yes, AJAX is the best way to do that. Also, as you don't wan't to submit the page so AJAX is the only solution.

For using AJAX the following steps have to be followed:
1. The section of the jsp that you want to replace with AJAX must be
embedded in a span tag.
2. call the retrieveURL method on click of required button in following
format retrieveURL(yourAction.do?ask=COMMAND_NAME_1',"yourFormBean");
3. This function will automatically pass control to your Action class (if
using Struts and get the required new values)

A sample ajax file is as below :


[ March 03, 2008: Message edited by: Anubhav Anand ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60072
    
  65

1. The section of the jsp that you want to replace with AJAX must be
embedded in a span tag.

Must be? No. It can be any structured element.
Anubhav Anand
Ranch Hand

Joined: May 18, 2007
Posts: 341

Originally posted by Bear Bibeault:

Must be? No. It can be any structured element.



Rigthly said Bear. I suppose I missed it.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: AJAX required or not
 
Similar Threads
Redirect to login in ajax...
Save button with Ajax
Displaying record from combo box
Upload a File Using jQuery
Can I have a response object content type = "null"?