Ok, so I was able to fix the caching issue with IE by using $.ajax instead of $.get and setting the cache option to false.
I was reading something about Firefox blocking all AJAX requests when it thinks that you're going across different domains - it thinks it's XSS - cross-site scripting. Apparently Opera must work the same way, since it doesn't respond to my AJAX requests either. So my question now is: Is there a way to test AJAX calls using the Django development server in Firefox and Opera? On Fri, Jun 11, 2010 at 11:58 PM, David Escobar <davidesco...@ieee.org>wrote: > Ok, that helped narrow things down a little bit. It seems that IE is > receiving the AJAX header after all. For some reason my JavaScript doesn't > always get rendered correctly in IE, but if I clear the browsing history, > cookies, temp files, etc., it works (at least until it starts caching things > again). So I'll have to play some more with that one. > > Firefox is still not receiving the AJAX header, however, and I did download > the Tamper data add-on, and when the Tamper Popup window appears, it > indicates that it IS sending an AJAX header: > > X-Requested-With: XMLHttpRequest > > However, it seems like request.is_ajax() is not picking it up (maybe it's > different than HTTP_X_REQUESTED_WITH?). The code I used for that URL is: > > def is_ajax_working(request): > if request.is_ajax(): > return HttpResponse("Received AJAX header %s." % > request.META["HTTP_X_REQUESTED_WITH"], mimetype="text/plain") > else: > return HttpResponse("Did not receive AJAX header.", > mimetype="text/plain") > > > Opera also fails every time. Safari and Chrome, however, work like a charm, > so I'm kind of at a loss here. Any other possibilities? Thanks. > > > On Wed, Jun 9, 2010 at 12:00 PM, Ryan <ryan.nieme...@gmail.com> wrote: > >> If you simplify things down to something like the snippets below, does >> the alert display 'Said it was NOT ajax' for you? It shouldn't (and >> doesn't for me). >> >> Also, do you have the Tamper Data Firefox add-on installed to validate >> the headers being sent in? That could help narrow things down. >> >> urls.py: >> >> (r'^isajax/?$', 'some_site.views.is_ajax_worky'), >> >> views.py: >> >> def is_ajax_worky(request): >> ajax_header = request.META.get('HTTP_X_REQUESTED_WITH', 'None') >> if request.is_ajax(): >> return HttpResponse('Said it WAS ajax. header=' + ajax_header) >> return HttpResponse('Said it was NOT ajax. header=' + ajax_header) >> >> test.html: >> >> <noscript>This test requires javascript!</noscript> >> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/ >> libs/jquery/1.4.2/jquery.min.js<https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js> >> "></script> >> <script type="text/javascript"> >> $(document).ready(function() { >> $.get('/isajax', function(data) { >> alert(data); >> }); >> }); >> </script> >> >> On Jun 9, 2:14 am, David Escobar <davidescobar1...@gmail.com> wrote: >> > Hi everyone, >> > I'm using Django 1.1 with jQuery 1.4.2 and currently testing with the >> > Django development server. Whenever I send an AJAX request with >> > $.get(), the HTTP_X_REQUESTED_WITH header only gets sent with Chrome >> > and Safari. It does not get sent with IE or Firefox. I've verified >> > this by outputting the request.META keys to a text file for each one. >> > Needless to say, my AJAX only works correctly with Chrome and Safari. >> > Also, I'm using request.is_ajax() on the Django side. >> > >> > Does anyone know why this might be occurring? Could it be because I'm >> > testing using the Django development server? It seems to me like this >> > might be a jQuery issue, but after doing many online searches, I >> > haven't seen anyone else run into this problem. Every documentation >> > says that jQuery sends HTTP_X_REQUESTED WITH. >> > >> > Thanks in advance. >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Django users" group. >> To post to this group, send email to django-us...@googlegroups.com. >> To unsubscribe from this group, send email to >> django-users+unsubscr...@googlegroups.com<django-users%2bunsubscr...@googlegroups.com> >> . >> For more options, visit this group at >> http://groups.google.com/group/django-users?hl=en. >> >> > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.