jquery-form / jquery-form/form

"data" option not sending through arrays

Open
#597 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
5.1k
Forks
2.1k
PR merge metrics
No merged PRs in 30d

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the report with jquery-form 4.3.0 and jQuery 3.5.1 using the shown data option with both strings and arrays or objects. Trace how the data option is serialized before submission; done means array and object values consistently reach the backend, with a regression test covering the behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, jquery
Domain
frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.