[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

passing multiple values using xmlhttp.send

Posted on 2010-08-21
4
Medium Priority
?
2,829 Views
Last Modified: 2012-05-10
I am using the script below to pass values from a form to a php page.  The first xmlhttp.send always returns a value, the second one is always blank. I am trying to figure out how to send multiple values using xmlhttp.send
if(xmlhttp) { 
  	var txtname = document.getElementById("txtname");
	var number  = document.getElementById("number");
    xmlhttp.open("POST","testing.php",true); //calling testing.php using POST method
    xmlhttp.onreadystatechange  = handleServerResponse;
    xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    xmlhttp.send("txtname=" + txtname.value); //Posting txtname to PHP File
	xmlhttp.send("number=" + number.value); //Posting number to PHP File
  }

Open in new window

0
Comment
Question by:brad0525
[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
4 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 2000 total points
ID: 33492405
what about :


xmlhttp.send("txtname=" + txtname.value + "&number=" + number.value);

or

xmlhttp.send("txtname=" + encodeURI(txtname.value) + "&number=" + encodeURI(number.value));

Open in new window

0
 

Author Closing Comment

by:brad0525
ID: 33492416
Thanks works perfect
0
 
LVL 1

Expert Comment

by:FractalPat
ID: 33492420
Have you tried something like this:

xmlHttp.send("txtname=txtname.value&number=number.value");
0
 
LVL 82

Expert Comment

by:leakim971
ID: 33492421
You're welcome! Thanks for the points!
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
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…

656 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