Gelmiş geçmiş en büyük porno sitemiz olan 2pe de her zaman en kaliteli pornoları sunmayı hedefledik. Diğer video sitemiz olan vuam da ise hd porno ağırlıklı çalışmalara başladık.

  1. #1
    Sencha User
    Join Date
    Sep 2011
    Location
    Taiwan
    Posts
    74
    Answers
    1
    Vote Rating
    0
    cwtuan is an unknown quantity at this point

      0  

    Default Unanswered: How to get server response after call model.save()

    Unanswered: How to get server response after call model.save()


    Hi
    I want to let user know why the request is failed after calling model.save().
    So I let server responses {"success":true,"msg": "XXX"}.
    But it seems that failure function is not able to get response.


    PHP Code:
    record.save({
        
    scopethis,
        
    success: function(recordoperation) {
            
    console.log(operation.response); // I can get server response in success        

        
    },
        
    failure: function(recordoperation) {
            
    console.log(operation.response); // undefined
        
    }
    }); 

    I have seen someone listen on a exception event in proxy to get the response,
    but it's not very graceful. Why does the failure can't get response?

  2. #2
    Sencha - Support Team slemmon's Avatar
    Join Date
    Mar 2009
    Location
    Boise, ID
    Posts
    4,781
    Answers
    356
    Vote Rating
    167
    slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold

      0  

    Default


    You can use a callback config in save() like below:

    Code:
    Ext.define('MyModel', {
        extend: 'Ext.data.Model',
        fields: ['name'],
        proxy: {
            type: 'ajax',
            url: 'data/json.json',
            reader: 'json'
        }
    });
    
    
    var model = Ext.create('MyModel');
    
    
    model.save({
        callback: function (records, operation, success) {
            if (!success) {
                console.log(operation.request.proxy.getReader().rawData.msg);
            }
        }
    });
    Example response:
    Code:
    {
        "success": false,
        "msg": "server response"
    }
    Or if you want to handle every server response globally you can do something like:
    Code:
    Ext.Ajax.on('requestcomplete', function (conn, response, options) {
        var resp = Ext.decode(response.responseText);
        if (resp.success === true) {
            cosnole.log('success = true');
        } else {
            console.log(resp.msg);
        }
    });
    Are you a Sencha products veteran who has wondered what it might be like to work at Sencha? If so, please reach out to our recruiting manager: sheryl@sencha.com

    C
    heck out all of the 2013 SenchaCon presentations here:
    http://www.sencha.com/blog/senchacon...now-available/

Thread Participants: 1

Tags for this Thread