Good day to all.

Like many here, I sit now writing a system in php.

I needed to get data from another domain. In their web interface, I spied an ajax request:

$.ajax({ url: '/lenta/get_last_opened_organization', success: function( data ){ $("#last_viewed").html(data) } }); 

I took it and inserted it with a link to their domain, it turned out like this:

  $.ajax({ url: 'http://domen/lenta/get_last_opened_organization', success: function( data ){ $("#last_viewed").html(data) } }); 

When making a request, the browser informed me:

 XMLHttpRequest cannot load http://domen/lenta/get_last_opened_organization. Origin http://my-domen.ru is not allowed by Access-Control-Allow-Origin. 

I do not exactly understand why but access is denied.
The question is how to pretend to make a request from their domain ..

ps
The jQquery AJAX documentation found the following:

 Due to browser security restrictions, most "Ajax" requests are subject to the same origin policy; the request can not successfully retrieve data from a different domain, subdomain, or protocol. 

Does this problem unsolvable ?!

    4 answers 4

    Access to other domains is prohibited for security purposes. To receive a response from another domain, this same domain must be configured for this in advance. Read this Data exchange between domains and this is JSONP

      Make a php-script on your server, let ajax access your script, and curl use the script to access that site, after receiving the result, pass it on to your site.

      • Option Babay, a good idea - user3521

      This is called a security policy, there is nothing to roam on other sites.

        If I'm not mistaken, then you need to change the current domain to the desired one, document.domain = " , like so, there is no editor at hand.

        • When you try to change the document.domain in js, SECURITY_ERR crashes ( - user3521
        • then without options ( - Andrei Arshinov