PDA

View Full Version : Code in tutorial returns error.



eddyyanto
30 May 2007, 9:17 AM
On the "Using Ajax" part of this tutorial : http://extjs.com/tutorial/introduction-ext, when I tried out the message loading as described in the tutorial, I get the following error message from firebug:



[Exception... "'Permission denied to call method XMLHttpRequest.open' when calling method: [nsIDOMEventListener::handleEvent]" nsresult: "0x8057001e (NS_ERROR_XPC_JS_THREW_STRING)" location: "<unknown>" data: no]


Note : I am using a webserver, and changed the url:



From:
url: [server url], // <-- replace with your url

To:
url: ['http://localhost/extjs/tutorials/post.php'],


which is accessible.

More info : Firefox 2 on Win XP.

tryanDLS
30 May 2007, 9:36 AM
Did you setup the virtual in IIS for extjs? Can you access that address by just typing it in a browser?

eddyyanto
30 May 2007, 10:28 AM
Did you setup the virtual in IIS for extjs? Can you access that address by just typing it in a browser?

I am using XAMPP on Windows, so I can forget about setting any virtual in IIS.
Yes, I can access the URL from the browser..

jsakalos
30 May 2007, 11:14 AM
Just generally...

For XHR to work you must have a web server (can be localhost) and request must be sent to same domain the main page is loaded from (same origin security policy). If you try to send request to another domain you get "Permission denied error".

This might be your case.

eddyyanto
30 May 2007, 6:08 PM
Just generally...

For XHR to work you must have a web server (can be localhost) and request must be sent to same domain the main page is loaded from (same origin security policy). If you try to send request to another domain you get "Permission denied error".

This might be your case.

I have been using a xampp localhost webserver on windows xp, and on the server part, both the link are located in:

http://localhost/extjs/tutorials/ExtStart.html -> contains html elements
http://localhost/extjs/tutorials/post.php -> returns some value during XHR call

both of the link are accessible and the second link is being parsed by PHP when it is being called.

I'll try to post my code:

1.
http://localhost/extjs/tutorials/ExtStart.html :



<div id="msg" style="visibility: hidden"></div>
Name: <input type="text" id="name" name="name" /><br />
<input type="button" id="okButton" value="OK" />



2. http://localhost/extjs/tutorials/post.php


Ext.onReady(function() {
Ext.get('okButton').on('click', function(){
var msg = Ext.get("msg");
msg.load({
url: ['http://localhost/extjs/tutorials/post.php'], // <-- replace with your url
params: "name=" + Ext.get('name').dom.value,
text: "Updating..."
});
msg.show();
});
});

eddyyanto
30 May 2007, 7:04 PM
Oooops, it works now....
Not sure if I am missing something before, I've restarted my box and now it works fine...
A little note on the localhost: we might need to add :


<?php
sleep(3); //add this to see the "updating..." animation
if(isset($_POST['name'])) {
echo 'From Server: '.$_POST['name'];
}
?>


Thanks.

jsakalos
30 May 2007, 11:30 PM
Congrats!

BTW, I'm pure Linux guy so I barely know what's Windows and I don't know what's xampp at all. ;)