我在一个简单的网站上使用python和js。
我试图从客户端调用一个方法并得到结果,但是不管我做什么
成功的功能没有发生。
这是我的JS$.ajax({
url: "http://127.0.0.1:8000/api/gtest/",
type: "POST",
data: { information : "You have a very nice website, sir."},
dataType: "json",
success: function(data) {
alert ("post is success");
},
error: function(request,error) {
alert(request.responseText);
alert(error);
}
});
这是我的服务器端代码def gtest(request):
jsonValidateReturn = simplejson.dumps({"jsonValidateReturn": "ddddd"})
return HttpResponse(jsonValidateReturn, content_type='application/json', mimetype='application/json')
服务器响应呼叫-
“POST/api/gtest/HTTP/1.1”200 31
尝试过类似的问题,但没有成功:\
不管我做什么,只调用错误函数。
错误警报始终为空。。没有实际消息。
我知道这可能是一个小变化,但我找不到。