 |
Account Login
|
 |
 |
Latest Articles
|
 |
 |
Advertisement
|
 |
 |
Associates
|
 |
 |
Associates
|
 |
|
 |
 |
|
 |
02-15-2008, 11:01 AM
|
#1 (permalink)
|
|
The Gregarious
Join Date: Dec 2007
Location: On your Hard Drive, hiding like a Virus
Posts: 734
Thanks: 153
|
xmlHttp.open is not a function
I keep getting this error for no reason at all.
Heres the code
Code:
var xmlHttp = new XMLHttpRequest;
xmlHttp.open("POST","*******************/?id=" + id + "&n=" + n, true);
__________________
Wax on, Wax off
|
|
|
|
02-15-2008, 11:18 AM
|
#2 (permalink)
|
|
The Addict
Join Date: Oct 2007
Location: Manchester, UK
Posts: 338
Thanks: 19
|
try:
Code:
var xmlHttp = new XMLHttpRequest();
__________________
There's nothing an agnostic can't do if he doesn't know whether he believes in anything or not
|
|
|
|
02-15-2008, 01:27 PM
|
#3 (permalink)
|
|
The Frequenter
Join Date: Nov 2007
Location: Netherlands
Posts: 393
Thanks: 46
|
Here's a little insight into the inner workings of XMLHttpRequest();
Ajax (XMLHTTPRequest) Tutorial and Demo
__________________
The Addict :: Addicted to (talk)PHP!
|
|
|
02-15-2008, 03:17 PM
|
#4 (permalink)
|
|
The Addict
Join Date: Oct 2007
Location: Manchester, UK
Posts: 338
Thanks: 19
|
i think the problem was he missed out the '( )', so therefore javascript wouldnt have seen the XMLHttpRequest class (in javascripts case, a function) and was looking for a var called XMLHttpRequest, it created the object but it didnt have the 'open()' method defined (once again function in the world of OO JS).
Im no expert in javascript but thats what i think he did wrong.
__________________
There's nothing an agnostic can't do if he doesn't know whether he believes in anything or not
|
|
|
|
02-15-2008, 06:16 PM
|
#5 (permalink)
|
|
The Acquainted
Join Date: Nov 2007
Posts: 153
Thanks: 31
|
Orc> Are you testing this with IE? IE doesn't have an XMLHttpRequest object.
I personally prefer the Wikipedia article, it's essentially the API for working with XHR.
__________________
I reject your reality, and substitute my own.
|
|
|
|
02-15-2008, 10:26 PM
|
#6 (permalink)
|
|
The Gregarious
Join Date: Dec 2007
Location: On your Hard Drive, hiding like a Virus
Posts: 734
Thanks: 153
|
Firefox, by the way, I tried it with the two parentheses before I took them out, it's the same error.
By the way, I've already seen tons of tutorials, I also have xmlHttp.open in a function, maybe that helps? Those are arguments inside it from the function.
__________________
Wax on, Wax off
|
|
|
|
02-15-2008, 10:34 PM
|
#7 (permalink)
|
|
The Gregarious
Join Date: Dec 2007
Location: On your Hard Drive, hiding like a Virus
Posts: 734
Thanks: 153
|
Heres the error from Firebug,

__________________
Wax on, Wax off
|
|
|
|
02-15-2008, 10:40 PM
|
#8 (permalink)
|
|
The Gregarious
Join Date: Dec 2007
Location: On your Hard Drive, hiding like a Virus
Posts: 734
Thanks: 153
|
What happened to the layout? But umm,
Code:
function ******* (n,id)
{
xmlHttp.open("POST","*****************/?id=" + id + "&n=" + n, true);
__________________
Wax on, Wax off
|
|
|
|
02-15-2008, 10:51 PM
|
#9 (permalink)
|
|
The Gregarious
Join Date: Dec 2007
Location: On your Hard Drive, hiding like a Virus
Posts: 734
Thanks: 153
|
The firebug also said it has something to do with an OnClick. The only OnClick is this:
Code:
onClick="********(1, '.$row['id'].')"
__________________
Wax on, Wax off
|
|
|
|
02-15-2008, 10:53 PM
|
#10 (permalink)
|
|
Moderateur
Join Date: Apr 2007
Posts: 613
Thanks: 2
|
You're not really giving us enough information to go on. Random snippets of code (which change continually) showing us the line that is 'broken' is a start but from what you've shown us there shouldn't be a problem.
Write "xmlHttp" (and press Enter) in the Firebug command line and see what it tells you.
__________________
|
|
|
|
02-15-2008, 10:59 PM
|
#11 (permalink)
|
|
The Gregarious
Join Date: Dec 2007
Location: On your Hard Drive, hiding like a Virus
Posts: 734
Thanks: 153
|
Quote:
Originally Posted by Salathe
You're not really giving us enough information to go on. Random snippets of code (which change continually) showing us the line that is 'broken' is a start but from what you've shown us there shouldn't be a problem.
Write "xmlHttp" (and press Enter) in the Firebug command line and see what it tells you.
|
Nothing.. It's just blue text listing. ;/
__________________
Wax on, Wax off
|
|
|
|
02-15-2008, 11:03 PM
|
#12 (permalink)
|
|
The Gregarious
Join Date: Dec 2007
Location: On your Hard Drive, hiding like a Virus
Posts: 734
Thanks: 153
|
Fine heres some of the code:
Code:
echo '<script type="text/javascript">
var xmlHttp = new XMLHttpRequest();
try {
// Intranet Explorer
xmlHttp = new ActiveXObject("Msxml.xmlHttp");
} catch (e)
{
xmlHttp = false;
}
try {
xmlHttp = new ActiveXObject("Micrsoft.xmlHttp");
} catch (e)
{
xmlHttp = false;
}
function userAmount (id,amount)
{
xmlHttp.open("GET","***********/screenshots/?id=" + id + "&ua=" + amount, true);
xmlHttp.send(null);
}
function stateEffect()
{
if (xmlHttp.readyState != 4)
{
starReturn.innerHTML = "<img src=\'http://***********/img/loading.gif\' alt=\'loading..\' title=\'Loading..\'> ";
return false;
} else if (xmlHttp.readyState == 4)
{
starReturn.value = "Successfully rated!";
} else {
starReturn.value = xmlHttp.responseText;
}
}
function StarRate (n,id,pre)
{
xmlHttp.open("POST","/?id=" + id + "&n=" + n + "&pre=" + pre, true);
xmlHttp.send(null);
starReturn = document.getElementById(\'starReturn\');
xmlHttp.onreadystatechange = stateEffect();
{
}
}
</style>';
Yes I am trying to make a rating system with AJAX. So far the AJAX fails.
__________________
Wax on, Wax off
|
|
|
|
02-15-2008, 11:13 PM
|
#13 (permalink)
|
|
The Gregarious
Join Date: Dec 2007
Location: On your Hard Drive, hiding like a Virus
Posts: 734
Thanks: 153
|
Code:
xmlHttp.open("POST","/?id=" + id + "&n=" + n + "&pre=" + pre, true);
It's just this one line is killing it all.
__________________
Wax on, Wax off
|
|
|
|
02-15-2008, 11:21 PM
|
#14 (permalink)
|
|
Moderateur
Join Date: Apr 2007
Posts: 613
Thanks: 2
|
The problem is in the way that you're creating the xmlHttp object. First you create an instance of XMLHttpRequest, then you try and use ActiveX which overwrites the already created object. That means, if the ActiveX object isn't available the xmlHttp object is rendered useless (as you know). You'll need to re-order/structure where you assign the new instance of whatever to xmlHttp such that you only try to use the IE approaches if 'new XMLHttpRequest' failed.
__________________
|
|
|
|
02-15-2008, 11:27 PM
|
#15 (permalink)
|
|
The Gregarious
Join Date: Dec 2007
Location: On your Hard Drive, hiding like a Virus
Posts: 734
Thanks: 153
|
Okay, thank you.. But now I get this:
Code:
uncaught exception: [Exception... "Could not convert JavaScript argument" nsresult: "0x80570009 (NS_ERROR_XPC_BAD_CONVERT_JS)" location: "JS frame :: ********************************* :: StarRate :: line 429" data: no]
// The line:
xmlHttp.send(null);
__________________
Wax on, Wax off
|
|
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
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
|
|
|
|