newbie needs help with AJAX

A

abhisek

Hello!
I don't know whether to post it over here since it's a javascript
group. But i am having trouble with aJax
I just started learning ajax with ajax for dummies. Very often i am
getting the same error message in firebug "uncaught exception:
Permission denied to call method XMLHttpRequest.open". What's
surprising is the same page that works with firefox is not working
with IE even if it has an ActiveXObject("Microsoft.XMLHTTP") object.
Help is much appreciated.
Regards
Abhisek
 
A

abhisek

Where else would you post it? ok.
Not a good book. Please suggest me a good book.
Show the code that causes that error.
Here it is:
var XMLHttpRequestObject = false;

if (window.XMLHttpRequest) {

XMLHttpRequestObject = new XMLHttpRequest();

} else if (window.ActiveXObject) {

XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHTTP");

}

function getData(dataSource, divID)

{

if(XMLHttpRequestObject) {

var obj = document.getElementById(divID);

XMLHttpRequestObject.open("GET", dataSource, false);

XMLHttpRequestObject.onreadystatechange = function()

{

if(XMLHttpRequestObject.readyState==1){obj.innerHTML='fetching...';}

if (XMLHttpRequestObject.readyState == 4 &&

XMLHttpRequestObject.status == 200) {

obj.innerHTML = XMLHttpRequestObject.responseText;

}

}

XMLHttpRequestObject.send(null);

}

}
Nothing about IE surprises me anymore. Show the code.
LOLZ!
 
A

abhisek

Oops! This are all the codes:
<html>

<head>

<title>Ajax at work</title>

<script language = "javascript">

var XMLHttpRequestObject = false;

if (window.XMLHttpRequest) {

XMLHttpRequestObject = new XMLHttpRequest();

} else if (window.ActiveXObject) {

XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHTTP");

}

function getData(dataSource, divID)

{

if(XMLHttpRequestObject) {

var obj = document.getElementById(divID);

XMLHttpRequestObject.open("GET", dataSource, false);

XMLHttpRequestObject.onreadystatechange = function()

{

if(XMLHttpRequestObject.readyState==1){obj.innerHTML='fetching...';}

if (XMLHttpRequestObject.readyState == 4 &&

XMLHttpRequestObject.status == 200) {

obj.innerHTML = XMLHttpRequestObject.responseText;

}

}

XMLHttpRequestObject.send(null);

}

}

</script>



</head>

<body>

<H1>Fetching data with Ajax</H1>

<form>

<input type = "button" value = "Display Message"

onclick = "showData('http://localhost/ajax/data.txt', 'targetDiv')">

</form>

<div id='targetDiv'>Nothing fetched</div>
 
S

ShutterMan

abhisek said the following on 1/25/2008 7:17 AM:


Where else would you post it?

Usenet isnt the only resource in the world, ya know..
Not a good book.

Your opinion - one of many.

Whats with the attitude here? The guy is being polite. If you'd rather
not respond to people, then don't.
 
A

abhisek

Your function is named getData, yet you are trying to call showData
Ok error corrected. But still the same error:
uncaught exception:
Permission denied to call method XMLHttpRequest.open
 
S

SAM

abhisek a écrit :
still the same error:
uncaught exception:
Permission denied to call method XMLHttpRequest.open

do you call a file from same domain ?

It seems that no : "Permission denied"

the cros-domain is forbidden.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top