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 1095753
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T00:10:30+00:00 2026-05-17T00:10:30+00:00

right now in my $.ajax({ ..}); call I have the following option: data: {

  • 0

right now in my $.ajax({ ..}); call I have the following option:

data: { param0: param0, param1: param1}

Say I want the number of parameters to by dynamic (based on a variable passed to the function in which the ajax call is made). How do I provide data: a dynamic set of parameters? I think I need to somehow construct an object (?) ahead of time (i.e. before the ajax call) and then pass this object to data:..but I’m not sure how to do this.

By variable passed in, I mean optional parameters which will be used as the GET params: param2 and param3 if they are passed in. So:

function myAjaxCall(param0, param1, param2, param3) { // param2/3 are optional
  $.ajax({
      //...
      data: { param0: param0, param1: param1} // this will need param2/3 if passed in
      //..
  });
}

So depending on if param2 and param3 are passed in (either, none or both is valid) I need the data object constructed accordingly.

  • 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-05-17T00:10:31+00:00Added an answer on May 17, 2026 at 12:10 am

    As you mentioned you need to make an object out of your parameters and pass it as data:

    var mydata = {
        name: 'ali',
        email: 'ali@example.com',
        ...
    }
    
    $.ajax({
        ...
        data: mydata,
        ...
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following JQuery AJAX call that sends HTML form data to my
I have a div that is receiving content from an ajax call. Right now
I have this ajax call at the moment: $.ajax({ url: misc/sendPM.php, type: POST, data:
I'm using jQuery Ajax call to fetch a list of images. Right now it
Right now I have an upload field while uploads files to the server. The
Right now, I have: RewriteRule ^([^/\.]+)?$ index.php?id=$1 [L] to match any username at the
Right now I have a script that will get the last five files in
Right now I have 3 tables: User, Roles, and User_Roles for the many-to-many association.
Right now I have a function, in a class that is used to listen
Right now I am using sqlite within a ios application, and I want to

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.