skip to Main Content

my data is not posting to django rest api using ajax – Jquery ajax

somehow my data is not posting to /api/recipe/recipes/ my html {% extends 'base.html' %} {% block content %} <!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Create a Recipe</title> </head> <body class=""> <form> {% csrf_token %} <br>…

VIEW QUESTION

Where my mistake in converting jquery ajax to pure js ajax request

That's my JQuery code which is currently working -> $("#newsLetter-form").on('submit',function(event){ event.preventDefault(); email = $('#emailId').val(); console.log(email); $.ajax({ url: '/subscribes/emailSubscribe', type:'POST', data:{ "_token": "{{ csrf_token() }}", email:email, }, success:function(response){ console.log(response); $('#responseFromSub').text("Registred!"); $('#responseFromSub').css('background','lightgreen') $('#newsLetter-form').css('display','none'); $('.sucsessMessage').fadeIn(1); setTimeout(function(){$('.sucsessMessage').fadeOut(1);$('#newsLetter-form').css('display','flex');},3000); }, error:function(response){ console.log(response); var val = 'asdasd:111122:123123123';…

VIEW QUESTION
Back To Top
Search