jquery-form / form

jQuery Form Plugin
https://jquery-form.github.io/form/
GNU Lesser General Public License v2.1
5.19k stars 2.14k forks source link

"data" option not sending through arrays #597

Open amhassen97 opened 3 years ago

amhassen97 commented 3 years ago

Description:

Hi

I am appending data to the ajax form when constructing the options object, The data I am appending is an array or object, which is linked to a key in the data object,

Expected Behavior:

The appended array or object used with the "data" property in the form options gets sent through to the backend.

Actual behavior:

This only works in some cases. If I append a string, the values go through fine, The issue seems to only occur with arrays and objects.

For example:

var formOptions = { beforeSubmit: validateRequest, // pre-submit callback success: showResponse, // post-submit callback error: showError, dataType: "json", data: {chosenPos : selectedPos, chosenNotifs : selectedNotifs}, resetForm: false, } selectedPos and selectedNotifs are arrays or objects with global scope. This has worked before, but for some reason now does not seem to. It is not consistent.

Thanks for the great library!

Versions:

jquery-form: 4.3.0 jQuery: 3.5.1