Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bfontaine/jquery-djangocsrf
A lightweight jQuery plugin to automatically add Django CSRF token to your AJAX calls
https://github.com/bfontaine/jquery-djangocsrf
django jquery js
Last synced: 14 days ago
JSON representation
A lightweight jQuery plugin to automatically add Django CSRF token to your AJAX calls
- Host: GitHub
- URL: https://github.com/bfontaine/jquery-djangocsrf
- Owner: bfontaine
- License: mit
- Created: 2014-03-21T09:21:59.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2024-06-27T14:59:59.000Z (6 months ago)
- Last Synced: 2024-12-08T21:03:20.162Z (16 days ago)
- Topics: django, jquery, js
- Language: JavaScript
- Size: 34.2 KB
- Stars: 9
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# jQuery Django CSRF Plugin
[![Build Status](https://travis-ci.org/bfontaine/jquery-djangocsrf.svg?branch=master)](https://travis-ci.org/bfontaine/jquery-djangocsrf)
The **djangocsrf** jQuery plugin makes it easy to use AJAX calls with Django’s
CSRF token.## Installation
[Download][release-0.1.1] and include the script *after* the jQuery library and
the Cookie library:```html
```
[release-0.1.1]: https://github.com/bfontaine/jquery-djangocsrf/releases/download/0.1.1/jquery.djangocsrf-0.1.1.min.js
## Usage
Enable the plugin:
```js
$.djangocsrf( "enable" );
```That’s all! After that, all AJAX calls made through jQuery to the current
domain will include an `X-CSRFToken` header set to the client’s token.Disable the plugin with `$.djangocsrf( "disable" )`, and query its current
state with `$.djangocsrf()`.## Tests
$ npm install -g grunt-cli
$ npm install -dRequires Node. Start the server:
$ node test/server.js
Then open `http://0.0.0.0:8124/test/index.html` in your browser.
Basic tests can also be run with `grunt`.