View Single Post
Old 12-18-2012, 05:56 AM   PM User | #1
navybofus
New to the CF scene

 
Join Date: Dec 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
navybofus is an unknown quantity at this point
Question HTTP Post Request and Response Displaying Problem

I've been working on a bit of code for a while now and I finally got it to work by testing it in an HTML file locally. I'm using an HTTP Post to send information to a sever that is set up to send a response back to me. I am using the following code to send the required fields, but it doesn't want to display the response in my DIVs after I've uploaded it to my web hosting. I have some PHP modules installed that should allow the XMLHttpRequest to work (HTML_Ajax and some others.) Basically I need a new set of eyes to look at this and see if there are any errors, or if I need to ask another question: "Why isn't my web hosting allowing my to show my responseText when it says that Ajax is compatible?"

Code:
<!DOCTYPE html>
<html>
<head>
<script>
function loadXMLDoc()
{
	var xmlhttp;
	var response;
	if (window.XMLHttpRequest)
		{// code for IE7+, Firefox, Chrome, Opera, Safari
			xmlhttp=new XMLHttpRequest();
		} else {// code for IE6, IE5
			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
		
	xmlhttp.onreadystatechange=function()
	{
		if (xmlhttp.readyState==4 && xmlhttp.status==200)
		{             
			response = xmlhttp.responseText; //Just showing a friend how variables work 
			document.getElementById("myDiv").innerHTML=response;
 *  	}
	}
	
	xmlhttp.open("POST","http://www.ssicat.com/smart/Updates.asmx/ActiveItemCount",false);
	xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
	xmlhttp.send("CustomerNumber=99994&UserName=99994&Password=71115&Source=99994");

	var xmlhttp1;
	
	if (window.XMLHttpRequest)
	{// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp1=new XMLHttpRequest();
	} else {// code for IE6, IE5
		xmlhttp1=new ActiveXObject("Microsoft.XMLHTTP");
	}

	xmlhttp1.onreadystatechange=function()
	{
		if (xmlhttp1.readyState==4 && xmlhttp1.status==200)
		{
			document.getElementById("myDiv1").innerHTML=xmlhttp1.responseText;
 *  	}
	}

	xmlhttp1.open("POST","http://www.ssicat.com/smart/Updates.asmx/GetItemDetails",true);
	xmlhttp1.setRequestHeader("Content-type","application/x-www-form-urlencoded");
	xmlhttp1.send("CustomerNumber=99994&UserName=99994&Password=71115&Source=99994&ItemNumber=3301");
}
</script>
</head>

<body onload="loadXMLDoc()">

<h2>TEST TEST</h2>

<div id="myDiv"></div>
<div id="myDiv1"></div>

</body>

</html>
Oh and that password is setup for testing, so no biggie. Thanks is advance.
navybofus is offline   Reply With Quote