File tree 1 file changed +20
-5
lines changed
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() {
825
825
} ;
826
826
827
827
this . showFields = function ( form ) {
828
+ var data = form . serializeArray ( ) ;
829
+ data = this . serializeForAjax ( form ) ;
830
+
828
831
$ . ajax ( {
829
832
url : formcreatorRootDoc + '/ajax/showfields.php' ,
830
833
type : "POST" ,
831
- data : form . serializeArray ( )
834
+ dataType : 'json' ,
835
+ data : data
832
836
} ) . done ( function ( response ) {
833
837
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' ] ;
838
841
} catch ( e ) {
839
842
// Do nothing for now
840
843
}
@@ -1430,6 +1433,18 @@ var plugin_formcreator = new function() {
1430
1433
1431
1434
return true ;
1432
1435
} ;
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
+ }
1433
1448
}
1434
1449
1435
1450
// === TARGETS ===
You can’t perform that action at this time.
0 commit comments