1👍
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”:
- Remove the javascript code you just added from the Django site
- Perform an AJAX POST to a csrf protected form
- Note that the POST fails