File tree Expand file tree Collapse file tree 1 file changed +20
-5
lines changed Expand file tree Collapse file tree 1 file changed +20
-5
lines changed Original file line number Diff line number Diff line change @@ -825,16 +825,19 @@ var plugin_formcreator = new function() {
825825 } ;
826826
827827 this . showFields = function ( form ) {
828+ var data = form . serializeArray ( ) ;
829+ data = this . serializeForAjax ( form ) ;
830+
828831 $ . ajax ( {
829832 url : formcreatorRootDoc + '/ajax/showfields.php' ,
830833 type : "POST" ,
831- data : form . serializeArray ( )
834+ dataType : 'json' ,
835+ data : data
832836 } ) . done ( function ( response ) {
833837 try {
834- var itemToShow = JSON . parse ( response ) ;
835- var questionToShow = itemToShow [ 'PluginFormcreatorQuestion' ] ;
836- var sectionToShow = itemToShow [ 'PluginFormcreatorSection' ] ;
837- var submitButtonToShow = itemToShow [ 'PluginFormcreatorForm' ] ;
838+ var questionToShow = response [ 'PluginFormcreatorQuestion' ] ;
839+ var sectionToShow = response [ 'PluginFormcreatorSection' ] ;
840+ var submitButtonToShow = response [ 'PluginFormcreatorForm' ] ;
838841 } catch ( e ) {
839842 // Do nothing for now
840843 }
@@ -1430,6 +1433,18 @@ var plugin_formcreator = new function() {
14301433
14311434 return true ;
14321435 } ;
1436+
1437+ /**
1438+ * Serialize a form without its csrf token
1439+ * @param {* } form
1440+ * @returns
1441+ */
1442+ this . serializeForAjax = function ( form ) {
1443+ var serialized = form . serializeArray ( )
1444+ return serialized . filter ( function ( item ) {
1445+ return item . name != '_glpi_csrf_token' ;
1446+ } ) ;
1447+ }
14331448}
14341449
14351450// === TARGETS ===
You can’t perform that action at this time.
0 commit comments