?
Solved

jquery ajax with concatenated variable

Posted on 2013-10-31
2
Medium Priority
?
208 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 2000 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

WordPress Tutorial 4: Recommended Plugins

Now that you have WordPress installed, understand the interface, and know how to install new parts, let’s take a look at our recommended plugins.

Question has a verified solution.

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

In this article you'll learn how to use Ajax calls within your CodeIgniter application. To explain this, I'll illustrate how to implement a simple contact form to allow visitors to send you an email through your web site.
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
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…
Suggested Courses

764 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