我有一个在Sencha Touch上运行的应用程序。它使用表单中的一些数据向Django服务器发出POST请求。这包含文本字段和图像文件。
显然,一切顺利。该应用程序能够正确地将数据发送到服务器,该服务能够接收数据并对其进行充分处理(包括图像文件)并以状态200回答它。客户端甚至收到此状态200.但是,回调函数在sencha touch app中调用的是失败的,而不是成功。
这是客户端收到的响应标头:
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: *
我正在使用以下方式进行POST:
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)
如何知道我做错了什么?
答案 0 :(得分:1)
来自sencha docs about form.submit
成功:功能
成功响应后将调用的回调。一个 如果从服务器收到响应,则响应成功 是一个JSON对象,其成功属性设置为true, {"成功":真实}。
因此,您的回复应该是有效的json,并且包含success:true
,如下所示:
{success: true, data: 'mydata'}