A friendly place for programming greenhorns!
Big Moose Saloon
Search
|
Java FAQ
|
Recent Topics
Register / Login
Win a copy of
Arduino in Action
this week in the
General Computing
forum!
A special promo:
Enter your blog post or vote on a blogger to be featured in an upcoming Journal
JavaRanch
»
Java Forums
»
Frameworks
»
Struts
Author
Struts 1 & JQuery & Ajax
Fred Artes
Ranch Hand
Joined: Nov 14, 2008
Posts: 43
posted
May 28, 2010 08:30:25
0
Please can you give me an example of code using Struts 1 & JQuery & Ajax ?
Without JQUery I have this
function loadBanks(){ selectAgency = document.getElementById('selectAgency '); selectedIdxAgency = selectAgency.selectedIndex; _selectedAgency = selectAgency[ selectedIdxAgency ].value; // get request url = "manageAgency.do?dispatch=loadBanks&idAgency=" + _selectedAgency ; // Calling ajax if( window.XMLHttpRequest ){ // Non IE req = new XMLHttpRequest(); req.onreadystatechange = populateBanksList; try{ req.open("GET", url, true); } catch(e){ alert("Error with server"); } req.send(null); } else if( window.ActiveXObject ){ //IE req = new ActiveXObject("Microsoft.XMLHTTP"); if( req ){ req.onreadystatechange = populateBanksList; req.open("GET", url, true); req.send(); } } }
Thanks
Karthik Jayachandran
Ranch Hand
Joined: Feb 18, 2009
Posts: 36
I like...
posted
May 31, 2010 00:16:40
0
Working with jQuery is so damn easy, you don't need this much code.
here's a small sample for your code,
$(function loadBanks(){ // Current selected value var selectedAgency=$("#selectAgency").val(); $.ajax({url:"manageAgency.do", data:"?dispatch=loadBanks&idAgency="+selectedAgency; success:showAgency, // On select, display 'Loading...' message beforeSend: function() { $('#wait').show(); }, // On complete stop displaying 'Loading...' message complete: function() { $('#wait').hide(); }, cache:false}); });
The resulting data will be handled by method called 'showAgency()'.
function showAgency(textData){ // process the data alert(textData); }
these might work.
David Newton
Author
Rancher
Joined: Sep 29, 2008
Posts: 12617
I like...
posted
Jun 01, 2010 06:01:32
0
There's nothing Struts-specific when using jQuery and Ajax--only the Ajax endpoint will have anything to do with Struts.
I agree. Here's the link:
http://ej-technologies/jprofiler
- if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
subject: Struts 1 & JQuery & Ajax
Similar Threads
How to change property of form bean from java script using AJAX
pass <bean:write> to a function
AJAX+STRUTS
Error in using window.XMLHttpRequest
Recursive call to a JavaScript method with AJAX call
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter