View Single Post
Old 24-04-2008, 11:23   #1
Millay
cf.mega poster
 
Millay's Avatar
 
Join Date: Oct 2003
Location: Portsmouth
Age: 30
Posts: 1,684
Millay has reached the bronze age
Millay has reached the bronze ageMillay has reached the bronze ageMillay has reached the bronze ageMillay has reached the bronze ageMillay has reached the bronze ageMillay has reached the bronze ageMillay has reached the bronze age
Send a message via MSN to Millay Send a message via Yahoo to Millay
Ajax Help needed.

Hi All I have the following script and everytime I click the submit button, I get an 'object expected' error on line 66, line 66 is the submit button line.

Can anybody help me debug this, im at the stage of staring blankley at it.

Many thanks
Andy

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script language="javascript">
function makeRequest() {

        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;
        }
        httpRequest.onreadystatechange = function() { alertContents(httpRequest); };
        httpRequest.open('POST', 'test.asp', true);
		httpRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
        httpRequest.send("imgfile=" + document.getElementById(‘imgfile’).value);

    }

    function alertContents(httpRequest) {

		if (httpRequest.readyState == 1) {
            var thingDisplay = document.getElementById('holiday');
			thingDisplay.innerHTML = '<b>LOADING...</b>';
            }

        if (httpRequest.readyState == 4) {
            if (httpRequest.status == 200) {
                //alert(httpRequest.responseText);
				var thingDisplay = document.getElementById('holiday');
			thingDisplay.innerHTML = httpRequest.responseText;
            } else {
				alert(httpRequest.responseText);
                //alert('There was a problem with the request.');
            }
        };
    };
</script>
</head>

<body>
<form>
  <input type="file" name="imgfile" id="imgfile">
  <INPUT TYPE="button" VALUE="Submit" onClick="makeRequest()">
</form>
<div id="holiday"></div>
</body>
</html>
Millay is offline   Reply With Quote