Question

i have an app running over Sencha Touch. It makes a POST request to a Django server with some data from a form. This contains textfields and a image file.

Aparently, everything goes ok. The app is capable to correctly send data to server, the serve is capable of receiving the data and process it adequately (including the image file) and answer it with a status 200. The client even receives this status 200. However, the callback function called in the sencha touch app is the failure one, not success.

This is the response header that the client receives:

HTTP/1.0 200 OK
Date: Thu, 08 May 2014 20:59:29 GMT
Server: WSGIServer/0.1 Python/2.7.6
Vary: Cookie
X-Frame-Options: SAMEORIGIN
Content-Type: text/html; charset=utf-8
Access-Control-Allow-Origin: *

I'm doing the POST using this:

values = form.getValues();
var request = {
    url: 'http://127.0.0.1:8000/profiles/create/',
    method: 'POST',
    success: function(conn, response, options, eOpts) {
        Ext.Msg.alert('Success!', 'We are happy!.');
    },
    failure: function(conn, response, options, eOpts) {
        Ext.Msg.alert('Error: status code ', response.status);

    },
    disableCaching: true,
    xhr2: true,
    progress: progressIndicator
}
form.submit(request)

How to known what i'm doing wrong?

Was it helpful?

Solution

From sencha docs about form.submit

success : Function

The callback that will be invoked after a successful response. A response is successful if a response is received from the server and is a JSON object where the success property is set to true, {"success": true}.

So your response should be a valid json and contain success:true like this:

{success: true, data: 'mydata'}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top