Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

problem making post request with multiple values

Status
Not open for further replies.

Edward07

Programmer
Apr 13, 2007
49
NL
i am tying to pass checkbox value and textbox value to this fuction and make xmlhttpreqest post request. Initial i used :
req.send("msg="+url);
and i posted msg only and it worked but when i try to post both msg and url it does not work. could any one look at this and let me know what i am doing wrong. I check using alert the data get passed corectly. Thanks

req.send("msg="+url&"url="+text);

Code:
<script>


// Make a POST to the server 
// and pass on any data from browser
// via the XMLHTTPRequest

function talktoServer3(){
    var req = newXMLHttpRequest();
	//register the callback handler function
  	var callbackHandler = getReadyStateHandler(req, updateMsgOnBrowser);
  	req.onreadystatechange = callbackHandler;
  	//req.open("POST", "servertime.php", true);
  	req.open("POST", "pushurl.php", true);
  	req.setRequestHeader("Content-Type", "application/x-[URL unfurl="true"]www-form-urlencoded");[/URL]
  	//get the value from the text input element and send it to server

//geting textbox data this next line
var text = document.getElementById('testmsg').value;
totalvotes = document.forms.mp3Play.totalvotes;


tempUrl ='';
url = '';

if (totalvotes.length > 0){  
 for (i=0; i<totalvotes.length; ++ i)
 {
	 if (totalvotes[i].checked)
	{
		tempUrl =tempUrl  + totalvotes[i].value +","
		if (i == 30)
		{
			alert("Each time you can only select 30 songs to play")
			return false;
		}
	}
 }
}
else
	{
		alert("it is less than 0#2")
		tempUrl = tempUrl + "&totalvotes=" + totalvotes.value
                

	}
	
	var url = "" + tempUrl.replace(/,$/,"");
	
req.send("msg="+url&"url="+text); 

}
 
You need a space between new and XMLHttpRequest();
Code:
var req = new XMLHttpRequest();

[monkey][snake] <.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top