$.ajax({
url: '/sorter/',
type: "get",
data: {
'k': 1
},
dataType: 'text',
success: function(data){
console.log(data);
}
}
);
def sorter(request):
if request.method == 'GET':
return HttpResponse('1')
else:
return redirect('http://127.0.0.1:8000')
from django.http import JsonResponse
def sorter(request):
if request.method == 'GET':
return JsonResponse('1')
else:
return redirect('http://127.0.0.1:8000')
Content-Type
application/json
.