trouble with my ajax request....

i have isolated problem down to these lines of code:

its does send anything to comphp.php


var age = document.getElementById('productid').value;
	var wpm = document.getElementById('memberid').value;
	var sex = document.getElementById('message').value;
	var parameters = "age=" + age + "&wpm=" + wpm + "&sex=" + sex;
	mypostrequest.open("POST", "comphp.php", true);
	mypostrequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	mypostrequest.send(parameters);

Open in new window

blink10Asked:
Who is Participating?
 
leakim971Connect With a Mentor PluritechnicianCommented:
next line too :
xmlhttp.send(parameters)
by :
ajaxRequest.send(parameters)
0
 
leakim971PluritechnicianCommented:
work fine : http://jsfiddle.net/kDEL4/

please provide a link to see your page in live
0
 
blink10Author Commented:
http://www.billsprice.com/com.php


If it works the message at the bottom will change, its not my php either...it worked fine with get and the php file is only printing the number 1 if it works..
0
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

 
leakim971PluritechnicianCommented:
replace :
xmlhttp.open("POST","comphp.php",true);
by :
ajaxRequest.open("POST","comphp.php",true);
0
 
blink10Author Commented:
ok why doesnt $pi = $_POST['pi']; pick up the parameters i sent?
0
 
leakim971PluritechnicianCommented:
you miss : ajaxRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
0
 
blink10Author Commented:
opps forgot to set headers, it works now, thanks.
0
 
leakim971PluritechnicianCommented:
... you missed
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.