Solved

jquery ajax with concatenated variable

Posted on 2013-10-31
2
200 Views
Last Modified: 2013-10-31
I am trying to set up a function that will pass in the field name as a concatenated word, with the name and the id passed in.
How can I write this:
$.post( "scripts/savecart.asp", { gift+id: '1', sessionVar: '1234' } );
0
Comment
Question by:rivkamak
2 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 39614803
var params = {};
params[gift+id]= '1'; // maybe you want : params["gift"+id]= '1'; 
params.sessionVar = '1234';
$.post( "scripts/savecart.asp", params );

Open in new window

0
 

Author Closing Comment

by:rivkamak
ID: 39614826
It worked with params["gift"+id]= '1'
Thank you
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer …
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question