aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes Can we use AJAX in my situation 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 "Can we use AJAX in my situation" Watch "Can we use AJAX in my situation" New topic
Author

Can we use AJAX in my situation

Ram kovis
Ranch Hand

Joined: Jun 23, 2005
Posts: 130
WE have a Search and a Search results JSPs

Upon entering Seardh criteria in Searh page, Stored procedure is called and the results are diaplyed in Search results page, which has around 30 columns in the HTML table.

Now we have column called Total $ in Search results page. To get data for this column, the stored proc has to query lots of tables and has a huge processing for calculating the total, which is hitting the perforamnce . So, we want to split the stored proc and the process of the page. i.e, First get data all 29 columns and display all the 29 columns in the results page and then we have to call another stored proc and get the the data for the total column. Can we use AJAX here? Can we add a new column dynamically .

Any suggestions sample code will be greatly apprecaited
Thanks
R
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61648
    
  67

Sure, you could use Ajax for that. But I'm not sure why you would think that making two requests would give you better performance than making one.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Ram kovis
Ranch Hand

Joined: Jun 23, 2005
Posts: 130
Originally posted by Bear Bibeault:
Sure, you could use Ajax for that. But I'm not sure why you would think that making two requests would give you better performance than making one.


Thanks Bear..
Since the stored proc takes a lot of time for the calulation of total column for each row,and eventually for the display the page with all the results, we want to split the processing. First diaply all 29 columns to user and then do the background processing for Total column and then display it as well in the results page.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61648
    
  67

Won't your users find it odd that the total suddenly appears out of nowhere after they've already been looking at the page for some time?

Irrespective of that, you're also setting yourself up for a race condition. What if, during the time you retrieve the columns and the time that the second request is initiated, something changes in the DB such that the total doesn't reflect the columns sent to the user? Such things are usually best done in a single transaction context.
Abhinav Srivastava
Ranch Hand

Joined: Nov 19, 2002
Posts: 349

In fact we have done exactly the same in our system, but it was only for showing the count of results. I think you should use some kind of summary tables to get the best performance.
[ November 17, 2006: Message edited by: Abhinav Srivastava ]
johny sil
Greenhorn

Joined: Jul 11, 2006
Posts: 13
[Thread hi-jack removed.

johny, start your own questions in your own topics]
[ November 19, 2006: Message edited by: Bear Bibeault ]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Can we use AJAX in my situation