Reputation: 261
Except for this article http://blog.springsource.com/2010/01/25/ajax-simplifications-in-spring-3-0/
I cannot find any good examples of the new AJAX related features in Spring 3.0. I am interested in how the web application build utilizing Spring MVC with Annotations can be integrated with the various AJAX frameworks, such as Dojo to provide rich user experience on the front end.
Upvotes: 2
Views: 3172
Reputation: 341
function YourJavaScriptFunctionHere(){
byObj1.loading()
setGridData(gridNon,[])
var url='dispatch=getMETHOD&PARAMETER='+Math.random()*9999;
var ajax=new ajaxObject('YOUR CONTROLLER MAPPING');
ajax.callback=function(responseText, responseStatus, responseXML) {
if (responseStatus == 200) {
var myArray = eval("("+responseText+")");
if(myArray["error"]){
alert(myArray["error"]);
}else{
setGridData(byObj1,myArray)
}
byObj1.loadingCompleted();
}
}
ajax.update(url,'POST');
}
Upvotes: 0
Reputation: 7568
var xhrArgs = {
url: "account/checkUsername/" +dojo.byId('').value,
handleAs: 'json',
load: function(response) { response(data);}
};
dojo.xhrGet(xhrArgs);
Upvotes: 1
Reputation: 597224
I think the article is pretty clear about the options. For example, based on it, I created the following method for verifying whether a username is in use or not:
/**
* @param username
* @return true if the username is free, false otherwise
*/
@RequestMapping("/account/checkUsername/{username}")
@ResponseBody
public boolean checkUsername(@PathVariable("username") String username) {
return userService.checkUsername(username);
}
And on the client side, using jQuery:
$("#username").live("blur", function() {
$.getJSON("account/checkUsername/" + $("#username").val(),
function(response) {
// do something with JSON response
}
);
});
Upvotes: 6