24-04-2008, 11:23
|
#1
|
|
cf.mega poster
Join Date: Oct 2003
Location: Portsmouth
Age: 30
Posts: 1,673
|
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>
|
|
|
24-04-2008, 11:26
|
#2
|
|
Cable Forum Team
Join Date: Jul 2003
Location: Poole, Dorset
Age: 23
Services: Sky+
V-Box
VM 10MBit
Posts: 9,154
|
Re: Ajax Help needed.
try putting a semi-colon after the () in the onClick statement
onClick="makeRequest();"
I remember reading somewhere that you couldn't upload images with Ayjax per se anyway
|
|
|
24-04-2008, 11:30
|
#3
|
|
cf.mega poster
Join Date: Oct 2003
Location: Portsmouth
Age: 30
Posts: 1,673
|
Re: Ajax Help needed.
thanks zeph, but no still object expected.
I am aware of what you are saying about ajax and uploading files, that is no strictly what im trying to acheive.
Thanks
Andy
|
|
|
24-04-2008, 11:32
|
#4
|
|
Eric Cartman Wannabe
Join Date: Jun 2003
Location: Cockney geeza land
Age: 27
Services: c:\> net start punky
Posts: 11,836
|
Re: Ajax Help needed.
Try changing:
document.getElementById(‘imgfile’).value
to
document.getElementById('imgfile').value
in case its that. If neither that or Zeph's idea works, then try putting alert statements in various places throughout the script to see at what point the script is failing.
__________________
"We're not here for a long time, we're here for a good time" - Mike Ness (Social Distortion)
"Reach for the sky, 'cause tomorrow may never come" - Reach For The Sky (Social Distortion)
|
|
|
24-04-2008, 11:35
|
#5
|
|
cf.mega poster
Join Date: Oct 2003
Location: Portsmouth
Age: 30
Posts: 1,673
|
Re: Ajax Help needed.
Thats cracked it thanks gavin
|
|
|
24-04-2008, 11:47
|
#6
|
|
Cable Forum Team
Join Date: Jul 2003
Location: Poole, Dorset
Age: 23
Services: Sky+
V-Box
VM 10MBit
Posts: 9,154
|
Re: Ajax Help needed.
Nicely done 
|
|
|
24-04-2008, 12:13
|
#7
|
|
Busy Admin
Join Date: Oct 2003
Location: Nottingham
Age: 45
Services: ntl Phone : Sky+ (with multiroom) : ntl Cable (20 Mbps)
Posts: 14,252
|
Re: Ajax Help needed.
Quote:
Originally Posted by Gavin
Try changing:
document.getElementById(‘imgfile’).value
to
document.getElementById('imgfile').value
|
Am I going blind here, whats the difference between these two lines 
__________________
Click here for a real, interactive, tv guide.
|
|
|
24-04-2008, 12:15
|
#8
|
|
Anyone can play guitar
Join Date: Jun 2003
Location: London way
Age: 32
Services: Women for money
Posts: 6,030
|
Re: Ajax Help needed.
Quote:
Originally Posted by Paul M
Am I going blind here, whats the difference between these two lines 
|
The types of quotes
|
|
|
24-04-2008, 12:17
|
#9
|
|
Cable Forum Team
Join Date: Jun 2003
Location: Sandy - Bedfordshire
Age: 33
Services: 20MB, Phone, Mobile, TV
Posts: 10,677
|
Re: Ajax Help needed.
the quotation marks are different
---------- Post added at 12:17 ---------- Previous post was at 12:16 ----------
and it was only 'cos i really am going blind i noticed lol  (My screen reader read both lines differently)
__________________
These are not the droids you are looking for.
|
|
|
24-04-2008, 12:57
|
#10
|
|
Cable Forum Team
Join Date: Jul 2003
Location: Poole, Dorset
Age: 23
Services: Sky+
V-Box
VM 10MBit
Posts: 9,154
|
Re: Ajax Help needed.
btw 
|
|
|
24-04-2008, 14:35
|
#11
|
|
Counteruh!!!
Join Date: Jun 2003
Posts: 10,116
|
Re: Ajax Help needed.
Quote:
Originally Posted by Zeph
btw 
|
More like 
__________________
Oh Oh Ranje 
We houden allemaal van jou, de spelers en het rood wit blauw.
------------------------------------------------------------------------
I wish I knew where I was going, cause I have to get back as well.
|
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT +1. The time now is 07:44.
|