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 8074095
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T14:32:41+00:00 2026-06-05T14:32:41+00:00

where do i put the ajaxSend code i found here: https://docs.djangoproject.com/en/1.2/ref/contrib/csrf/#ajax I mean, i

  • 0

where do i put the ajaxSend code i found here:

https://docs.djangoproject.com/en/1.2/ref/contrib/csrf/#ajax

I mean, i have a base htm file that has a section, which looks a bit like this:

<script>
    $(function() {
        $("#loginThing").click(function(){
            ... and then i define buttons to be pressed etc etc
    });
</script>

so what? do i put the code above the ${function(){}); call (but in the script tags)? do i put it in the function call? do i have to change it – the way it is called, perhaps – in any way shape or form?

i stuck it above the $(function()) call (but in the script tag), but its not like my ajax calls are behaving any differently. In fact, i don’t have the foggiest notion how to test if this is doing anything. I’m not using any test code (i know, terrible. but this is a learning progress. also, i don’t like test code). Is there some way i can “manually” test this? Like, using nothing but firefox?

  • 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-05T14:32:43+00:00Added an answer on June 5, 2026 at 2:32 pm

    where do i put the ajaxSend code

    It just needs to be outside of your present function definition.

    <script>
        $(function() {
            $("#loginThing").click(function(){
                // ... and then i define buttons to be pressed etc etc
        });
    
        $(document).ajaxSend(function(event, xhr, settings) {
            // ... Rest of function goes here
        });
    </script>
    

    Is there some way i can “manually” test this? Like, using nothing but firefox?

    I can’t tell you how to test it in Firefox as I don’t use it. However, Chrome has a built in interface that’s great for this.

    Open your page in Chrome and hit Command-Option-I (on a mac, Windows is likely similar). Go to the Network tab. In the left most column you should see the url of your POST request. Click on it. It will give you all the details you’ll need to explore, Cookies (look for csrftoken to make sure Django’s csrf cookie is present in the page), request and response headers, etc.

    its not like my ajax calls are behaving any differently. In fact, i don’t have the foggiest notion how to test if this is doing anything.

    They should be, you just can’t “see” it. Use the Chrome tools as explained above to view the communications with the server. To confirm that it “is doing anything”:

    1. Remove the javascript code you just added from the Django site
    2. Perform an AJAX POST to a csrf protected form
    3. Note that the POST fails
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Put it another way: what code have you written that cannot fail. I'm interested
Put simply I have an ajax call that sometimes completes before the page is
Or put in another way, would it be suggested to have separate stack (context,
I'm learning Ajax at the moment. The code below basically receives the echo from
Put simply, I have a WCF service that manages apples. Apart from other functionality,
Put this in your location bar in IE javascript:location.href='http://www.google.com/search?q=something&lt=bar' Watch in horror as it
Put simply: I want the following code to print sub: Element e = new
I put this code into all of my viewControllers: UIInterfaceOrientation orientation = [[UIApplication sharedApplication]
I want to make a php ajax post.(post value without refresh the page) here
Simply put, I have a website where you can sign up as a user

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.