equal
deleted
inserted
replaced
51 } |
51 } |
52 }); |
52 }); |
53 }) |
53 }) |
54 } |
54 } |
55 |
55 |
56 $.ajaxSetup({ |
|
57 beforeSend: function(xhr, settings) { |
|
58 function getCookie(name) { |
|
59 var cookieValue = null; |
|
60 if (document.cookie && document.cookie != '') { |
|
61 var cookies = document.cookie.split(';'); |
|
62 for (var i = 0; i < cookies.length; i++) { |
|
63 var cookie = jQuery.trim(cookies[i]); |
|
64 // Does this cookie string begin with the name we want? |
|
65 if (cookie.substring(0, name.length + 1) == (name + '=')) { |
|
66 cookieValue = decodeURIComponent(cookie.substring(name.length + 1)); |
|
67 break; |
|
68 } |
|
69 } |
|
70 } |
|
71 return cookieValue; |
|
72 } |
|
73 if (!(/^http:.*/.test(settings.url) || /^https:.*/.test(settings.url))) { |
|
74 // Only send the token to relative URLs i.e. locally. |
|
75 xhr.setRequestHeader("X-CSRFToken", getCookie('csrftoken')); |
|
76 } |
|
77 } |
|
78 }); |
|