how do I get the ajax XMLHTTP request to work in the Android browser?

I am trying to build a web application for the Android, but my XMLHTTP request does not work.  I currently have the web app working in Safari on the iPhone.  I have searched the internet extensively and found articles that say the Android browser does support the XMLhttp request and some that say it does Not work.  

Here is a good article:

What is the deal?  Is XMLHTTP supported or not?  Is there something special I have to do for the Android?   Can you give me an example of an XMLHTTP request working on the Android?

Thanks for the help!

This works in Mobile Safari, but not Android 2.0.1:

function getCurrentStatusBatch(){
      xhttp = new XMLHttpRequest();
      var batchReq = '<list is="obix:BatchIn">';
      //get current Thermostat Mode  (0=off, 1=Cool, 2=Heat, 3=Auto)   node=0
      batchReq += '<uri is="obix:Read" val="' + BaseURL + BasePoint + aptNum + '/Logic/SystemMode/out/" />';
      //get current Hold (0=no hold active, 1=hold active)    node=1
      batchReq += '<uri is="obix:Read" val="' + BaseURL + BasePoint + aptNum + '/Logic/Schedule/HoldType/out/" />';
      batchReq += '</list>';
      //"POST", "", false, "admin");"POST", "/obix/batch", false, "admin");
      if (xmlDoc.length == 0){
      alert("somethin in there")}
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Hello jfBLOOM22,

Try the script in the code snippet, it work for me (I get a responseText) with Android 2.1 :

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script language="javascript">
	window.onload = function() {
		var xmlhttp = null;
		if(window.XMLHttpRequest) { xmlhttp=new XMLHttpRequest(); } else{ xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); }

		if(xmlhttp == null) {
			alert("your browser don't support Ajax");
		else {
//			alert("your browser support Ajax");"GET","simple.php",false);
			alert( "responseText : " + xmlhttp.responseText );

Open in new window

WebKit support CSS, Javascript, DOM and...AJAX

simple.php :

	echo "banana split";
        // Yep, very simple...

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jfBLOOM22Author Commented:
The issue ended up being with the webserver.  We are using something called NiagaraAX to host the website, and for some reason it is responding to the xmlhttp request without the header information.  for whatever reason the Safari browser does not seem to mind, but the Palm and Android browsers think the document is empty.

The solutions helped me troubleshoot and narrow down the issue.  Thanks for the help?
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Browsers

From novice to tech pro — start learning today.