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?
It just needs to be outside of your present function definition.
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
csrftokento make sure Django’s csrf cookie is present in the page), request and response headers, etc.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”: