![]() |
xmlHttp.open is not a function
I keep getting this error for no reason at all.
Heres the code Code:
var xmlHttp = new XMLHttpRequest; |
try:
Code:
var xmlHttp = new XMLHttpRequest(); |
Here's a little insight into the inner workings of XMLHttpRequest();
Ajax (XMLHTTPRequest) Tutorial and Demo |
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. |
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. |
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. |
Heres the error from Firebug,
![]() |
What happened to the layout? But umm,
Code:
function ******* (n,id) |
The firebug also said it has something to do with an OnClick. The only OnClick is this:
Code:
onClick="********(1, '.$row['id'].')" |
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. |
Quote:
|
Fine heres some of the code:
Code:
echo '<script type="text/javascript"> |
Code:
xmlHttp.open("POST","/?id=" + id + "&n=" + n + "&pre=" + pre, true); |
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.
|
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] |
| All times are GMT. The time now is 02:33 PM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0