1. #1
    Sencha User
    Join Date
    Dec 2012
    Location
    India
    Posts
    8
    Vote Rating
    0
    tanujkhanna9 is on a distinguished road

      0  

    Default Unanswered: Ext.Ajax.Request - Servlet

    Unanswered: Ext.Ajax.Request - Servlet


    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:

    ExtJs:

    var button = Ext.create('Ext.Button', {
    text: 'Reach Servlet!!!',
    handler: function() {
    Ext.Ajax.request({
    url : 'ExportCsvServlet',
    method:'POST',
    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){
    debugger;
    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.setContentType("text/html");
    response.getWriter().print("{success: true, errorMessage: 'Error'}");
    }

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,647
    Vote Rating
    898
    Answers
    3575
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    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?
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha User
    Join Date
    Dec 2012
    Location
    India
    Posts
    8
    Vote Rating
    0
    tanujkhanna9 is on a distinguished road

      0  

    Default


    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 ???

Thread Participants: 1

Tags for this Thread