Solved

jquery ajax with concatenated variable

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to dynamically set the form action using jQuery.
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…

840 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