Results 1 to 4 of 4

Thread: Apply decodeURIComponent() for every AJAX response

  1. #1
    Sencha User
    Join Date
    Sep 2011
    Location
    Taiwan
    Posts
    106
    Answers
    1
    Vote Rating
    4
      0  

    Default Unanswered: Apply decodeURIComponent() for every AJAX response

    Hi,
    For some reason, we have to encode Chinese characters in unicode at server side.
    But when loading a grid, I have to decode all of them again. An Example is shown below.
    PHP Code:
    columns : [  {
            
    dataIndex 'name',
            
    renderer : function(value) {
                return 
    decodeURIComponent(value);
            }
        },{
            
    dataIndex 'address',
            
    renderer : function(value) {
                return 
    decodeURIComponent(value);
            }
        }

    Is it possible to apply decodeURIComponent() for every AJAX response by default so that I don't have to write decodeURIComponent() for every grid column?

    Many thanks!
    Tony

  2. #2
    Sencha User
    Join Date
    Jan 2012
    Posts
    1,376
    Answers
    347
    Vote Rating
    114
      0  

    Default

    Try to apply decoding at model definition by using field convert().

  3. #3
    Sencha User
    Join Date
    Sep 2011
    Location
    Taiwan
    Posts
    106
    Answers
    1
    Vote Rating
    4
      0  

    Default

    Quote Originally Posted by vietits View Post
    Try to apply decoding at model definition by using field convert().
    Hi, vietits
    Thanks for your reply!
    This method still needs to implement a converter for each model field.
    It would be better if we can apply decodeURIComponent() for all Ext.Ajax's response so that we don't have to do the dirty job.
    Thanks!

  4. #4
    Sencha User
    Join Date
    Jan 2012
    Posts
    1,376
    Answers
    347
    Vote Rating
    114
      0  

    Default

    If so, you can listen for 'requestcomplete' event from Ext.Ajax:
    Code:
    Ext.Ajax.on('requestcomplete', function(connection, response, options){
        // your code here
    });

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
  •