Solved

passing multiple values using xmlhttp.send

Posted on 2010-08-21
4
2,412 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
  • 2
4 Comments
 
LVL 82

Accepted Solution

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Sending E-mail ASP.Net 3 55
jquery wizard next doesn't go to top of tab 4 51
Working with SharePoint Data 8 46
alert before form submission 6 27
This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
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…

948 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

18 Experts available now in Live!

Get 1:1 Help Now