/    Sign up×
Community /Pin to ProfileBookmark

loading HTTPS page from an HTTP page using Ajax

Hello,
i’m fairly new to ajax. I have a page, 1.php, that loads 2.php using ajax. 2.php is protected by ssl and basic authentication, and 1.php is an unprotected page.
i’ve been trying to load 2.php using ajax with no luck.

if 1.php is loaded using https, 2.php would load up just fine(prompt user for username and password). however if 1.php is loaded using HTTP, the call to 2.php using HTTPS won’t work using XMLHttpRequest.open. it throws this error:

Error: uncaught exception: [Exception… “Access to restricted URI denied” code: “1012” nsresult: “0x805303f4 (NS_ERROR_DOM_BAD_URI)” location: “http://libdmr.dhcp.bsu.edu/cdm4/jscripts/ajax.js Line: 34″]

could someone point me to a right direction?

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@TeufelAug 13.2009 — I don't think it can - usually cross-domain requests aren't possible. And yes, that counts for https://, too.
Copy linkTweet thisAlerts:
@TeufelAug 13.2009 — However, what you can do, is use alternative ajax:

Either you create an invisible iframe out of which you can read content, or if you only need GET, you can just do the following:

[CODE]function ajax() {
new Image().src = "https://domain.com/script.php?parameter=value&name=Alf";
}
ajax();
[/CODE]


This way, you can still transport your data, but only if you're using GET.
×

Success!

Help @bajinganindy spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...