 |
Account Login
|
 |
 |
Latest Articles
|
 |
 |
IRC Channel
|
 |
 |
Associates
|
 |
 |
Associates
|
 |
|
 |
 |
|
 |
02-15-2008, 11:01 AM
|
#1 (permalink)
|
|
The Prestige
Join Date: Dec 2007
Posts: 1,042
Thanks: 193
|
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);
__________________
VillageIdiot can have my babbies ;d
|
|
|
|
02-15-2008, 11:18 AM
|
#2 (permalink)
|
|
The Prestige
Join Date: Oct 2007
Location: Manchester, UK
Posts: 836
Thanks: 31
|
try:
Code:
var xmlHttp = new XMLHttpRequest();
__________________
mysql> SELECT * FROM `users` WHERE `users`.`clue` > 0;
Empty set (0.00 sec)
|
|
|
|
02-15-2008, 01:27 PM
|
#3 (permalink)
|
|
The Frequenter
Join Date: Nov 2007
Location: Netherlands
Posts: 460
Thanks: 49
|
Here's a little insight into the inner workings of XMLHttpRequest();
Ajax (XMLHTTPRequest) Tutorial and Demo
__________________
"Life is a bitch, take that bitch on a ride"
|
|
|
02-15-2008, 03:17 PM
|
#4 (permalink)
|
|
The Prestige
Join Date: Oct 2007
Location: Manchester, UK
Posts: 836
Thanks: 31
|
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.
__________________
mysql> SELECT * FROM `users` WHERE `users`.`clue` > 0;
Empty set (0.00 sec)
|
|
|
|
02-15-2008, 06:16 PM
|
#5 (permalink)
|
|
The Acquainted
Join Date: Nov 2007
Posts: 154
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 Prestige
Join Date: Dec 2007
Posts: 1,042
Thanks: 193
|
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.
__________________
VillageIdiot can have my babbies ;d
|
|
|
|
02-15-2008, 10:34 PM
|
#7 (permalink)
|
|
The Prestige
Join Date: Dec 2007
Posts: 1,042
Thanks: 193
|
Heres the error from Firebug,

__________________
VillageIdiot can have my babbies ;d
|
|
|
|
02-15-2008, 10:40 PM
|
#8 (permalink)
|
|
The Prestige
Join Date: Dec 2007
Posts: 1,042
Thanks: 193
|
What happened to the layout? But umm,
Code:
function ******* (n,id)
{
xmlHttp.open("POST","*****************/?id=" + id + "&n=" + n, true);
__________________
VillageIdiot can have my babbies ;d
|
|
|
|
02-15-2008, 10:51 PM
|
#9 (permalink)
|
|
The Prestige
Join Date: Dec 2007
Posts: 1,042
Thanks: 193
|
The firebug also said it has something to do with an OnClick. The only OnClick is this:
Code:
onClick="********(1, '.$row['id'].')"
__________________
VillageIdiot can have my babbies ;d
|
|
|
|
02-15-2008, 10:53 PM
|
#10 (permalink)
|
|
Moderateur
Join Date: Apr 2007
Posts: 1,239
Thanks: 3
|
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.
__________________
salathe@php.net
|
|
|
|
02-15-2008, 10:59 PM
|
#11 (permalink)
|
|
The Prestige
Join Date: Dec 2007
Posts: 1,042
Thanks: 193
|
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. ;/
__________________
VillageIdiot can have my babbies ;d
|
|
|
|
02-15-2008, 11:03 PM
|
#12 (permalink)
|
|
The Prestige
Join Date: Dec 2007
Posts: 1,042
Thanks: 193
|
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.
__________________
VillageIdiot can have my babbies ;d
|
|
|
|
02-15-2008, 11:13 PM
|
#13 (permalink)
|
|
The Prestige
Join Date: Dec 2007
Posts: 1,042
Thanks: 193
|
Code:
xmlHttp.open("POST","/?id=" + id + "&n=" + n + "&pre=" + pre, true);
It's just this one line is killing it all.
__________________
VillageIdiot can have my babbies ;d
|
|
|
|
02-15-2008, 11:21 PM
|
#14 (permalink)
|
|
Moderateur
Join Date: Apr 2007
Posts: 1,239
Thanks: 3
|
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.
__________________
salathe@php.net
|
|
|
|
02-15-2008, 11:27 PM
|
#15 (permalink)
|
|
The Prestige
Join Date: Dec 2007
Posts: 1,042
Thanks: 193
|
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);
__________________
VillageIdiot can have my babbies ;d
|
|
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
| 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
|
|
|
|