weixin_33674437 2015-03-24 22:46 采纳率: 0%
浏览 21

无法完成Ajax的工作

ajax done doesnt fire when receive json file. it prints json object out client side

$.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 ");
            });

on service side, I got json file from client

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

on browser , I didnt see any error code. i get 200. but console output "ajax failed" please help

  • 写回答

1条回答 默认 最新

  • weixin_33688840 2015-03-24 22:53
    关注

    why not use:

    $.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 ");
               }
           });
    
    评论

报告相同问题?