ExtJS + Django. How to submit form with POST method -
firstly, should checked threads @ stackoverflow have connection topic, still not working solution. so, when seek submit form error: 'forbidden (403). csrf verification failed. request aborted....'
. this:
var frm=ext.create('ext.form.panel',{ method:'post', standardsubmit:false, items:[{ xtype:'textarea', name:'sourcecode', value:sourcecode }] }) frm.getform().submit({url:'/myapp/savesourcecode'})
in fact, not know how send csrf cookie
. suggestion, have seen not help @ all. so, need simplest working demo, demonstrate in simplest possible way how should send forms post method. in advance!
the issue here comes csrf cooki.
you can seek ( wc3 school docs )
example (not tested) :
function getcookie(cname) { var name = cname + "="; var ca = document.cookie.split(';'); for(var i=0; i<ca.length; i++) { var c = ca[i]; while (c.charat(0)==' ') c = c.substring(1); if (c.indexof(name) != -1) homecoming c.substring(name.length,c.length); } homecoming ""; } var csrf = getcookie('csrftoken') var frm=ext.create('ext.form.panel',{ method:'post', standardsubmit:false, items:[{ csrfmiddlewaretoken:csrf, xtype:'textarea', name:'sourcecode', value:sourcecode }] }) frm.getform().submit({url:'/myapp/savesourcecode'})
hope helps.
django extjs
No comments:
Post a Comment