Problem with callback in submit()

  • Hello all, I have a problem which confusing me greatly.
    I have code like this:


    new Ext.Button
    ({
    id: 'template_sumbit',
    text: 'создать шаблон',
    formBind: true,
    handler:
    function ()
    {
    var oForm = this.ownerCt.getForm();
    if(oForm.isValid() == true)
    {
    oForm.submit(
    ({
    url: 'controller.php',
    clientValidation: true,
    params: { func: 'create_template' },
    waitTitle: 'Соединение с сервером',
    waitMsg: 'Отправка данных...',
    success:
    function ()
    {
    add_log_message('Шаблон успешно создан', new Date().format('H:i:s d-m-Y'), 'edit', 'system');
    },
    failure:
    function (oForm, oAction)
    {
    if(oAction.failureType == 'server')
    {
    add_log_message('Шаблон создать не удалось ' + Ext.util.JSON.decode(oAction.response.responseText ).errors.reason, new Date().format('H:i:s d-m-Y'), 'error', 'system');
    }
    else
    {
    add_log_message('Шаблон создать не удалось (проверьте соединенние c сервером)', new Date().format('H:i:s d-m-Y'), 'error', 'system');
    }
    }
    }));
    }
    else
    {
    Ext.Msg.alert('Ошибка', 'Проверьте правильность заполнения полей');
    }
    }
    })


    For research purposes controller.php gives response like: '{ foo: 'test' }'.

    After completing the request ALWAYS callback failure is invoked. Response text in failure function gives '{ foo: 'test' }'. I couldn't understand WHY IT IS FAILURE? I tried to use both 'success' and 'callback' functions, neither invoked. Firebug gives no errors and load correct response.

    So my question is: why failure method is invoked in my case?


  • Solved my problem, forgot about {success: true} in JSON response. Sorry for topic.







  • #If you have any other info about this subject , Please add it free.#
    Your name:
    E-mail:
    Telphone:

    Your comments:


    If you have any other info about Problem with callback in submit() , Please add it free.

    7 January 2009 | cameltoepants.com | edit