I've tested this and it does not work....i have tried using onsubmit, onclick, onmousedown, onmouseup and it still doesn't do anything.
i.e. onsubmit="makeRequest('data.php')"
here is my coding....am i doing something incorrectly?
-
<script type="text/javascript" language="javascript">
-
function makeRequest(url) {
-
var httpRequest;
-
-
if (window.XMLHttpRequest) { // Mozilla, Safari, ...
-
httpRequest = new XMLHttpRequest();
-
if (httpRequest.overrideMimeType) {
-
httpRequest.overrideMimeType('text/xml');
-
// See note below about this line
-
}
-
}
-
else if (window.ActiveXObject) { // IE
-
try {
-
httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
-
}
-
catch (e) {
-
try {
-
httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
-
}
-
catch (e) {}
-
}
-
}
-
-
if (!httpRequest) {
-
alert('Giving up :( Cannot create an XMLHTTP instance');
-
return false;
-
}
-
-
//enter var details for fields here
-
var urlparams = "first_name=" + encodeURIComponent(document.getElementById("first_name").value);
-
urlparams += "&last_name=" + encodeURIComponent(document.getElementById("last_name").value);
-
urlparams += "&address1=" + encodeURIComponent(document.getElementById("address1").value);
-
urlparams += "&address2=" + encodeURIComponent(document.getElementById("address2").value);
-
urlparams += "&city=" + encodeURIComponent(document.getElementById("city").value);
-
urlparams += "&state=" + encodeURIComponent(document.getElementById("state").value);
-
urlparams += "&zip=" + encodeURIComponent(document.getElementById("zip").value);
-
urlparams += "&os0=" + encodeURIComponent(document.getElementById("os0").value);
-
urlparams += "&email=" + encodeURIComponent(document.getElementById("email").value);
-
-
-
httpRequest.onreadystatechange = function() { alertContents(httpRequest); };
-
httpRequest.open('POST', url, true);
-
httpRequest.send('urlparams');
-
-
}
-
-
function alertContents(httpRequest) {
-
-
if (httpRequest.readyState == 4) {
-
if (httpRequest.status == 200) {
-
alert(httpRequest.responseText);
-
} else {
-
alert('There was a problem with the request.');
-
}
-
}
-
-
}
-
</script>
-