我有一个JQuery .ajax()
请求尝试从服务器获取答案。但是我收到了错误
SyntaxError:JSON.parse:第1行第2列的意外字符 JSON数据
所以,这是javascript代码:
$.ajax({
...
success: function(response){
...
},
error: function(response){
let resp = JSON.parse(response);
console.log(resp);
saveButton.html('<i class="fa fa-warning">' + response.error + '</i>');
}
});
所以,这是DRF响应:
class SaveStockitemsTable(APIView):
renderer_classes = (JSONRenderer,)
def post(self, request, retailer_id):
if not activation_date_string:
return Response({"error": "No activation_date_string found"}, status=status.HTTP_400_BAD_REQUEST)
if not table_data:
return Response({"error": "No table data found"}, status=status.HTTP_400_BAD_REQUEST)
renderer_classes
属性不起作用,或者我错过了一些明显的东西吗?