ExtJS + django formulario enviar problema de éxito / error

I have a problem when dealing with the callback of a form submit, the code in client side is:

[...]
buttons: [{
    text: 'submit',
    formBind: true,
    handler: function(){
         formPanel.getForm().submit({
         url: this.actionUrl,
         waitMsg: TR['formdialog.messages.saving'],
         success: function(form, action) {
             this.close();
         },
         failure: function(form, action) {
             if(action.failureType == Ext.form.Action.CLIENT_INVALID) {
                 Ext.Msg.alert('Failure', 'Client invalid');
             }else if(action.failureType == Ext.form.Action.CONNECT_FAILURE){
                 Ext.Msg.alert('Failure', 'Connect failure');
             }else if(action.failureType == Ext.form.Action.SERVER_INVALID){
                 Ext.Msg.alert('Failure', 'Server invalid');
             }else{
                 Ext.Msg.alert('Failure', action.result.msg);
             }
         }
         [...]

In the server side, the code is as simple as:

response = {'success':True, 'msg': 'Everything went better than expected'}
print response
return HttpResponse(content=json.dumps(response))

When trying with Firefox 3.6.17 the form remains with the wait message and does nothing. With Firebug 1.7.2 it can be seen in the net tab, the petition to the server and in console (running the server with runserver) I can see the print of the response. However, the action.response is empty and in Firebug I see an "Aborted" status. If I set breakpoints in success and failure it seems that the execution is not going through neither of them :S (is there any other possible case?).

When trying with Chrome 7.0.517.44 the execution seems to go through success (which is correct) but action.response is also empty and console reflects "Failed to load resource" (although in server console the response is correctly printed).

Noticias: With HttpFox I can see a NS_ERROR_NET_RESET (as well as with wireshark I can see that a packet with RST flag is sent by the server), but I have no clue of the reason of this behaviour :S.

preguntado el 08 de noviembre de 11 a las 16:11

¿Encontraste alguna solución para esto? -

No :( I can't figure out the reason of the problem... -

1 Respuestas

Try to set mimetype="application/json" in your view function

respondido 08 nov., 11:20

Tried with return HttpResponse(content=json.dumps(response), mimetype="application/json") and same result. Also, I forgot to say that with wireshark I see tcp packet with RST flag - user1035942

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.