Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8552247
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T14:23:01+00:00 2026-06-11T14:23:01+00:00

I would like to pass data from a dynamically built form via ajax to

  • 0

I would like to pass data from a dynamically built form via ajax to a php script, but have trouble finding the correct syntax for the parameter string format.
There’s a couple of fixed parameters and some are added dynamically, keys and values of the latter may change.

I’ve tried to build the parameter list as a concatenation of strings as below:

...
var dataVars = '{fctSelect: 2, strat: strat, ' + gbl.dataVariables + '}';

...

$j.ajax({
    url: "ajax/script.php",
    type: "POST",
    data: dataVars,
...

gbl.dataVariables is formatted as follows : ‘field1: value1, field2: value2, field3, value3’

The resulting string to go into data “looks right” in console.log, but in the post tab of the console once the field validated, it appears like this:

{fctSelect: 2, strat: strat, ...

instead of:

fctSelect: 2
strat: 1
...

meaning that the parameters are not parsed. Could someone please point me to where I went wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T14:23:02+00:00Added an answer on June 11, 2026 at 2:23 pm

    Darin Dimitrov’s solution is probably the way to go for you, I’ll just give you an alternative. If you collect your form’s fields and their values through serialize(), you can simply append your static data like this:

    var dataVars = $('form').serialize(),
        dataVars += dataVars.length > 0 && '&'; // in case there are no form fields
        dataVars += 'fctSelect=2&strat=somevalue';
    
    $j.ajax({
        url: 'ajax/script.php',
        type: 'POST',
        data: dataVars,
        success: function() {}
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to pass data from a database column to another page via
I have a form that has label values that I would like to pass
I would like to pass some data structures from java to perl. In perl,
I would like to pass certain data from an instance of an object to
I would like to know how can I pass data from controller to view
I would like to pass a MYSQL query via Coldfusion the following date: 03/13/2010
I have a ratingbar in my app, and I would like when I pass
How can I pass data from client to server? I have a very simple
I would like to be able to pass a parameter in a callback, but
I would like to validate both single field and multiple field data from a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.