Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
AJAX "Access is Denied" Error
Old 07-26-2008, 01:33 PM AJAX "Access is Denied" Error
Super Talker

Posts: 116
Trades: 0
I am attempted to make a firefox add-on that will send data to an external server (sort of like those stumbleupon and del.icio.us addons) with information about what page you're on. however, i want to do this with ajax rather than with forms. The info is populated with predefined variables and are populated with prompt / other info.

now, my problem is that since i'm trying to send the data to an external server, my ajax keeps returning an "access is denied" error. (i actually spent a really long time figuring that out - firefox didn't give any errors since it was an extension... i eventually had to make a new file of jus the ajax to test it in ie so i could see the exact error.)

i tried changing the chmod of the files on my server to 777 and i still got the access denied error. is there some way to get it to work?

or will i have to like open a new window with a page from my site and let them do their stuff there? (since thats what those social bookmarking sites seem to do... i think... but all of the windows look similar if not the same just a different header, so im not so sure).

thanks
__________________


Please login or register to view this content. Registration is FREE

nasaboy007 is offline
Reply With Quote
View Public Profile Visit nasaboy007's homepage!
 
 
Register now for full access!
Old 07-26-2008, 10:05 PM Re: AJAX "Access is Denied" Error
Extreme Talker

Posts: 238
Location: United States
Trades: 0
Ajax will only work if the server you are trying to connect to has the same domain name as the website the Ajax request is on. This is called the same origin policy, and all major browsers adhere to it.

I'm not familiar with creating Firefox add-ons or XUL, but I'm sure there's an alternate method to send data to and from external servers besides Ajax.
__________________
The interlocking pieces of web development: usability, performance, accessibility, and standards.
frost is offline
Reply With Quote
View Public Profile
 
Old 07-26-2008, 10:57 PM Re: AJAX "Access is Denied" Error
Super Talker

Posts: 116
Trades: 0
I see. Well, firefox addons are basically XML to make the menus, which call javascript functions with oncommand (aka onclick, etc). so i think the only way to do it would be with javascript... what other ways are there to send data to and from external servers since ajax won't work? i only know th ebasics of javascript, and am no pro.
__________________


Please login or register to view this content. Registration is FREE

nasaboy007 is offline
Reply With Quote
View Public Profile Visit nasaboy007's homepage!
 
Old 07-27-2008, 10:07 AM Re: AJAX "Access is Denied" Error
upstarter's Avatar
Average Talker

Posts: 26
Name: Starr Horne
Trades: 0
There is a way to get around this limitation. You can't send a cross-domain XHR request, but you can include a javascript file from a remote domain. So you use a little piece of javascript in your extension, to load another piece of javascript from your remote server.
PHP Code:
 function include(filename) {     var head document.getElementsByTagName('head')[0];          script document.createElement('script');     script.src filename;     script.type 'text/javascript';          head.appendChild(script) } 
And here's the sneaky part - you pass your data in the querystring of the javascript request. Your server then takes the data, processes it, and returns the result in the form of a javascript expression which will be executed on the client.
__________________
my company:
Please login or register to view this content. Registration is FREE


my blog:
Please login or register to view this content. Registration is FREE
upstarter is offline
Reply With Quote
View Public Profile Visit upstarter's homepage!
 
Old 07-27-2008, 02:28 PM Re: AJAX "Access is Denied" Error
Super Talker

Posts: 116
Trades: 0
actually, thanks for the suggestions, but i found the solution.

http://developer.mozilla.org/en/docs...XMLHttpRequest


Just added a
PHP Code:
<?php header('Access-Control: allow <*>'); ?>
to my php file that was doing the ajax processing.

thread can be closed.
__________________


Please login or register to view this content. Registration is FREE

nasaboy007 is offline
Reply With Quote
View Public Profile Visit nasaboy007's homepage!
 
Old 05-03-2009, 08:13 AM Re: AJAX "Access is Denied" Error
Junior Talker

Posts: 3
Name: PeteWilson
Trades: 0
This cross-domain restriction is easy to overlook. Be sure that you're opening your xmlhttp connection from exactly the same domain that your browser is in. For example, if I've opened my browser in pwilson.net and the page I've loaded tries to open a connection to www.pwilson.net, that connection fails.

-- Pete
pete142 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to AJAX "Access is Denied" Error
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.23348 seconds with 12 queries