Anyway, in my effort of building a GMail Contextual gadget i have to send some data to a http server using xmlHttpRequest. The gadget runs in an iFrame which will stop you from using xmlHttpRequest. It's called cross domain blocking or something. So the first you'll have to do is to short circuit the cross domain blocking by adding the header "Access-Control-Allow-Origin: *" to the response.
If you don't do this you will inevitably get redystate=4 and status=0 (or 'unknown' or something) for the xmlHttpRequest object.
The second mistake i made was the trigger button for the request. Using a submit input and the onClick event will generate two callbacks. One to the forms action, and one to the actual function you specified in the onClick. This messes things up and you're back with status=0 problem again.
Solution: Use input type="button". This input will not trigger the forms actionl.
<form name="fakeform" action="return false;" >
<input type="button" value="Go" onClick="doRequest();" />