2015-03-24 44 views
0

ajax做的时候接收json文件并不火。它打印JSON对象了对服务端 客户端无法得到Ajax做的作品

,我得到了来自客户端

def post(self): 
    print self.request.body 
    print tornado.escape.json_encode(self.request.body) 
    self.set_header("Content-Type", "application/json") 
    self.write("{}") 

JSON文件上的浏览器,我没有看到任何错误代码。我得到200.但控制台输出“AJAX失败” 请帮助

回答

0

为什么不使用:

$.ajax({ 
     type: "POST", 
     url: url, 
     processData: false, 
     dataType: 'json', 
     contentType: 'application/json', 
     data: data, 
     success: function(){ 
      console.log("Sample of data:"); 
      alert("hello"); 
       }, 
     error: function() { 
      console.log("ajax failed "); 
      } 
     }); 
+0

成功和错误会所做代替,失败。对? – cppython 2015-03-24 22:54:52

+0

是的,就像我在那里写的那样。使用成功和错误属性,而不是完成和失败 – atomCode 2015-03-24 22:56:31

+0

“完成是实现成功回调的首选方式”从jquery网站 – cppython 2015-03-24 22:58:18