无法完成 ajax 项工作
unable to get ajax done works
ajax 接收 json 文件时不会触发完成。它打印出 json 对象
客户端
$.ajax({
type: "POST",
url: url,
processData: false,
dataType: 'json',
contentType: 'application/json',
data: data
}).done(function() {
console.log( "Sample of data:");
alert("hello");
}).fail(function() {
console.log("ajax failed ");
});
在服务端,我从客户端
获得了json文件
def post(self):
print self.request.body
print tornado.escape.json_encode(self.request.body)
self.set_header("Content-Type", "application/json")
self.write("{}")
在浏览器上,我没有看到任何错误代码。我得到 200。但控制台输出 "ajax failed"
请帮忙
为什么不使用:
$.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 ");
}
});
ajax 接收 json 文件时不会触发完成。它打印出 json 对象 客户端
$.ajax({
type: "POST",
url: url,
processData: false,
dataType: 'json',
contentType: 'application/json',
data: data
}).done(function() {
console.log( "Sample of data:");
alert("hello");
}).fail(function() {
console.log("ajax failed ");
});
在服务端,我从客户端
获得了json文件 def post(self):
print self.request.body
print tornado.escape.json_encode(self.request.body)
self.set_header("Content-Type", "application/json")
self.write("{}")
在浏览器上,我没有看到任何错误代码。我得到 200。但控制台输出 "ajax failed" 请帮忙
为什么不使用:
$.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 ");
}
});