Results 1 to 6 of 6

Thread: Reading the response from the server before it is loaded into a store

  1. #1

    Default Answered: Reading the response from the server before it is loaded into a store

    Hello,
    I have a JSON store that gets data from a remote server through a PHP script. Sometimes the script throws errors and therefore the Store fails to load. I would like to control that from the client side but I have not been able to find an event that fires AFTER the response has been received but BEFORE the data is loaded onto the store.
    I need such event to access the responseText from the response.

    Does anyone know which event I should use?

    Thanks in advance

  2. If you use Ajax server proxy, then let try the following code:
    Code:
    Ext.Ajax.on('requestcomplete', function(conn, response, options){
        // your code here
    });

  3. #2
    Sencha User
    Join Date
    Oct 2011
    Posts
    25
    Answers
    1

    Default

    meet the same situation. waiting for answer

  4. #3

    Default

    Nobody???
    Or is it so obvious that the ExtJS Gods cannot be bothered :-) ?

  5. #4
    Sencha User
    Join Date
    Dec 2011
    Posts
    224
    Answers
    13

    Default

    u dont even need extjs for this, just use firebug in firefox or developer tools or w/e in chrome

    this way u can see the data sent to the server and the data response from the server and there u check if an error in the data sent or data received

    or i misunderstood ur question :d maybe u want to send an error msg from the php script and on the client side u recive this msg and do something ? :d

  6. #5
    Sencha User
    Join Date
    Jan 2012
    Posts
    1,376
    Answers
    347

    Default

    If you use Ajax server proxy, then let try the following code:
    Code:
    Ext.Ajax.on('requestcomplete', function(conn, response, options){
        // your code here
    });

  7. #6

    Default Thanks

    Great, that works fine.
    Since I have many different requests in my application, I can't handle all the exceptions in the same way. I have to delegate the handling to the request proxy.

    Here is the code:
    Code:
    Ext.Ajax.on('requestcomplete', function(conn, response, options){ 
    try{ 
    eval("(" + response.responseText + ')') 
    } 
    catch(e){ 
    var proxy=response.request.options.scope; 
    proxy.fireEvent('exception'); 
    } 
    });
    After this, I just need to create the 'exception' event listener for the proxies that I want.

    Now, I know I shouldn't use eval() to evaluate the validity of my JSON response, but that was the easiest thing to do.

    Thanks again

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •