Jump to content

Loading http://www.bla.com... AJAX that call https://secure.bla.com... Possible?


ltrem

Recommended Posts

Hey guys,

 

I want to know if it is possible to call, with AJAX function, a link that doesn't have the same domain name...

 

Here is the pattern:

 

the page http://www.bla.com is loaded ,

 

there is an onclick button that call a Javascript function ,

 

in that function, there is some AJAX. The AJAX call a script on a different domain which is that one : https://secure.bla.com

 

Is this possible?

 

Currently not working, and was wondering if it was only possible and if yes, how?

Link to comment
Share on other sites

The XMLHttpRequest object is coded to not allow requests to a different domain for security reasons.  There are ways around it though.  The easiest way around it is to just use a framework like jQuery for your AJAX stuff.

Link to comment
Share on other sites

basicly that second example is jsonp (json with padding). I do think you need access to the server for the script that gives the json response since it's a bit different.

 

The following example I found using google http://a.webvm.net/ you can even see the php source which makes the jsonp possible.

 

If you don't have access to the server you want to use that will output a response, then you're better off using cURL or just any serverside script that can read remote data. With a script like that you could make a remote ajax call a local ajax call.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.