I am working on a spring 2.5.4 project, where I need to get an ajax response that returns a integer value on ajax request. Is there is some way I can do it?
For now, I believe all ajax calls either returns a page or a part of page.
The sample code I am using for ajax request with prototype is as follows,
var ajaxSourceTable = new Ajax.Request(
'../fetch/timeout.html?ajax=true',
{ method:'post',
parameters:{},
onSuccess:function(t){
/*alert time out here*/
alert(t.responseText);
},
onFailure:function(t){
alert("Request failed ! Please report the issue : "+t.responseText);
}
}
);
Your
../fetch/timeout.html?ajax=truehas to return the single value. You should rather write a controller for that which returntext/plainorapplication/jsonwith the data in the response body.