Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
O
OHR Support
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
97
Issues
97
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
OHR Support
Commits
61c00779
Commit
61c00779
authored
Mar 25, 2012
by
Andrew Smith
Committed by
Felix Schäfer
May 20, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Set the X-CSRF-Token header for AJAX requests with jQuery. #950
parent
375045a8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
1 deletion
+9
-1
application.js
public/javascripts/application.js
+9
-1
No files found.
public/javascripts/application.js
View file @
61c00779
...
...
@@ -467,7 +467,15 @@ jQuery.viewportHeight = function() {
// Automatically use format.js for jQuery Ajax
jQuery
.
ajaxSetup
({
'beforeSend'
:
function
(
xhr
)
{
xhr
.
setRequestHeader
(
"Accept"
,
"text/javascript"
)}
'beforeSend'
:
function
(
xhr
)
{
xhr
.
setRequestHeader
(
"Accept"
,
"text/javascript"
);
// TODO: Remove once jquery-rails (Rails 3) has been added a dependency
var
csrf_meta_tag
=
jQuery
(
'meta[name="csrf-token"]'
);
if
(
csrf_meta_tag
)
{
xhr
.
setRequestHeader
(
'X-CSRF-Token'
,
csrf_meta_tag
.
attr
(
'content'
));
}
}
})
/* TODO: integrate with existing code and/or refactor */
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment