[Answered ]-No POST-Data from Ajax in Django

2๐Ÿ‘

โœ…

I found the part wich was wrong (Javascript):

Here is the new JavascriptPart (which works for me):

var arr = {};
arr["first"] = "first";
arr["second"] = "second";
arr["third"] = "third";
var success = ""
$.ajax({
type: "POST",
url: "/AJAX?modus=create",
data: {"data": JSON.stringify(arr)},
success: success,
dataType: "application/json",
headers: {"X-CSRFToken": getCookie('csrftoken')}
});

And this is the django-part (view):

def AJAX(request):
  if request.method == 'POST':
      method = request.REQUEST.get("modus","")
      if method == 'create':
          data = request.POST.get('data');
๐Ÿ‘คLee

Leave a comment