Solved

jquery ajax with concatenated variable

Posted on 2013-10-31
2
195 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
There are a couple ways to attach a JavaScript function to dynamically created elements. You can make a new script for each element as it’s created or you can use delegation. Delegation allows a single script that is added at page creation to mat…
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…

758 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now