0

我无法从服务器获得响应.. 我来自 html 的 ajax 请求命中 django 中的视图,django 返回响应,但回调函数没有收到任何内容...问题出在哪里?这是我的代码:

$.ajax({ // create an AJAX call...
                type: "GET", // GET or POST
                url: "djuka/", // the file to call
                dataType: "json",
                contentType: 'application/json',
                success: function(response) { // on success..
                    alert("aaaa");
                }
            });

并查看:

def djuka(request):
if request.is_ajax():
    print "-->YES"
return HttpResponse(json.dumps({'message' : 'awesome'},ensure_ascii=False), mimetype='application/javascript')

print "-->YES" 被执行但 alert("aaaa") 从未被调用.....

4

1 回答 1

0

尝试删除打印语句。它使响应无效的 JSON。

于 2013-09-08T09:50:50.373 回答