View Full Version : Ext.Ajax.Request - Servlet

12 Feb 2013, 3:58 AM
I am trying to make an Ajax Call through a servlet, My request reaches servlet, but the response is not handled by the Ext Js.

Not sure if issue is on server side or ExtJs,

Following below is the code of the same:


var button = Ext.create('Ext.Button', {
text: 'Reach Servlet!!!',
handler: function() {
url : 'ExportCsvServlet',
scope : this,
//method to call when the request is successful
success : this.onLoginSuccess,
//method to call when the request is a failure
failure : this.onLoginFailure

onLoginSuccess : function(response,opts){
alert('we got outout from servlet in success!!!!!');
onLoginFailure : function(err){
alert('we got outout from servlet in fault !!!!!');

---------------------------------Server Side------------------------------------------------------------

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
System.out.println("We are in servlet at last !!!!! ");
response.getWriter().print("{success: true, errorMessage: 'Error'}");

13 Feb 2013, 8:42 PM
Using the developer tools with the network tab, you can see the request and response, is the response what you expect?Is the success or failure getting executed?

13 Feb 2013, 10:49 PM
Hi, I was able to retrieve the response. thanks for the tip.

My next step is to retrieve the response of type 'text/csv' so that the browser can forcefully allow download of a file (csv).

Can this be achieved by ExtJs.AhaxRequest or i need to make an independent Ajax Request ??

Any tip in this regard ???