Skip to content
Advertisement

How can access input value in django view through AJAX without form submission

I am beginner in django.I am working on a single text box in a django form which have number of fields.I wrote AJAX code for passing each value(entered from keyboard). How can i access this value in django class based view code. I want to save this value into a variable. Here i am trying to check given text is already existing or not. checking is done for each keyboardinput.

JavaScript

Advertisement

Answer

You should change the format of data you have in a json format so that you can embed csrf_middleware_token into the POST :

JavaScript

And then in backend, you can access it by using request.POST["text"]

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement