You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
functiongetCookie(name){varcookieValue=null;if(document.cookie&&document.cookie!==''){varcookies=document.cookie.split(';');for(vari=0;i<cookies.length;i++){varcookie=jQuery.trim(cookies[i]);// Does this cookie string begin with the name we want?if(cookie.substring(0,name.length+1)===(name+'=')){cookieValue=decodeURIComponent(cookie.substring(name.length+1));break;}}}returncookieValue;}varajaxOption={beforeSend: function(xhr,settings){if(settings.type=='POST'||settings.type=='PUT'||settings.type=='DELETE'){if(!(/^http:.*/.test(settings.url)||/^https:.*/.test(settings.url))){// Only send the token to relative URLs i.e. locally.xhr.setRequestHeader("X-CSRFToken",getCookie('csrftoken'));}}}};varclient=new$.RestClient('/api/rest/',{"ajax": ajaxOption});
The text was updated successfully, but these errors were encountered:
Can you add following example to documentation
Sourses:
https://gist.github.com/alanhamlett/6316427
https://docs.djangoproject.com/en/dev/ref/csrf/#ajax
I spent some time with this, may be it will be helpful for someone.
The text was updated successfully, but these errors were encountered: