开发者

Using AJAX in django

开发者 https://www.devze.com 2023-01-03 11:43 出处:网络
I am new to AJAX and django. I have written my own XMLHttpRequest call on browser side. I will have to manually set the header request.META[\'HTTP_X_REQUESTED_WITH\'] to string XMLHttpRequest.

I am new to AJAX and django.

I have written my own XMLHttpRequest call on browser side. I will have to manually set the header request.META['HTTP_X_REQUESTED_WITH'] to string XMLHttpRequest.

How can I access 开发者_运维技巧these headers on browser side?


Use HttpRequest.is_ajax(). See the docs.


Some post about django and ajax: Django AJAX Tutorial Part 1 - adding email to newsletter


If you want an easy to use solution for impolementing ajax ni django, I would recommend dajax i am using it in my own project and it simplifies things a lot.

of cause you wont be able to customize it as much as with your own programming but especially for beginners its pretty useful

0

精彩评论

暂无评论...
验证码 换一张
取 消