Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8630309
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T09:01:50+00:00 2026-06-12T09:01:50+00:00

$.ajax({ url:’/’, type: POST, data: {name: ‘name’, age: ‘age’}, success:function(response){}, complete:function(){}, error:function (xhr, textStatus,

  • 0
$.ajax({
    url:'/',
    type: "POST",
    data: {name: 'name', age: 'age'},
    success:function(response){},
    complete:function(){},
    error:function (xhr, textStatus, thrownError){}
});

And in views.py:

class SomeView(generic_views.TemplateView):
    template_name = 'something.html'

    def get(self, request, *args, **kwargs):
        ...something...
        return self.render_to_response(context)

    def post(self, request, *args, **kwargs):
        name = request.POST['name']
        age = request.POST['age']
        ...something...

And I get: [05/Oct/2012 12:03:58] “POST /something/ HTTP/1.1” 403 2294

I’d like to send this data(name and age) via jQuery to this post function in “SomeView”. This is the same view as the loaded template, just the request type is different. On get() the template loads and on post, the post() function should be called. Is it possible? I’ve checked other questions and got this solution. It was supposed to be working. What am I doing wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T09:01:52+00:00Added an answer on June 12, 2026 at 9:01 am

    The answer to your question what you are doing wrong, is: not much!

    Django returns a 403 response (Forbidden) if an incoming POST request fails Csrf checks.
    You can do this through jQuery’s ajaxSetup, code snippets are found here

    The reason that this DOES work on a GET request, is simply that GET requests are not checked by the csrf middleware.

    As it seems you are building a form here, another thing to consider is using class based forms. They handle get/post and also parameter validation for you. Very neat. Especially when you are making forms to edit/create/delete model instances, in which case you can embrace the power of ModelForms and CreateViews. Very neat.

    It might take some time to get the hang of those generic class based views. But it’s very well worth it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

function stationMenu($scope){ $.ajax({ url: /users/station_names_ajax, type: POST, success: function(data){ $scope.phones = [ {name: Nexus
jQuery code: function ajaxsubmit(){ $.ajax({ url: /update, type: POST, dataType: html }).success(function(data) { $('#result').html(data);
I have an ajax function: $.ajax({ url: 'http://localhost/process.php', type: 'post', data: '', success: function(output)
here's my jquery: $.ajax({ url: 'function.php', type: 'post', datatype: 'json', success: function(data){ var toAppend
jQuery.ajax( { url:'http://en.wikipedia.org/wiki/Football', type:'get', dataType:'jsonp', success:function(data){alert(data);}, } i want to read wikipedia page from
$(function(){ $.ajax({ url: 'http://xxx/', type: 'GET', crossDomain:true, cache:true, dataType:script, success:function(data,textStatus,jqXHR){ alert(data); } }); });
$($.ajax({ url: 'http://localhost:3606/runs', //beforeSend: function (xhr) { // xhr.setRequestHeader(Origin, http://localhost:2286/); //}, success: function(data) {
I have this script: $.ajax({ url: 'submit_to_db.php', type: 'POST', data: 'name=' + name +
$.ajax({ url: '/create_lead', data: { name: $('#lead_gen_name').val(), lead_gen[email]: $('#lead_gen_email').val(), }, type: 'POST', dataType: 'json',
I send request like $.ajax({ url: 'php_scripts/reload_fancoils.php', type: 'POST', dataType: 'json', data:parameters, success: function(data){

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.