0

Possible Duplicate:
Access Control Allow Origin not allowed by
Origin is not allowed by Access-Control-Allow-Origin

I used this code to call a vaadin application from PHP page:

$.get(
    "http://192.168.10.106:8080/FTTBManager/?restartApplication",
    { activate: "1", username: "Ahmed1.Hiwa@gold" }, 
    function(result) {
        alert ("Result Was : " +result);
        $('#divout').html(result); 
    }, 
    "text" 
)

but I get the following error:

Origin localhost is not allowed by Access-Control-Allow-Origin.

Community
  • 1
  • 1
danarj
  • 1,798
  • 7
  • 26
  • 54
  • Where is this code running from? `http://192.168.10.106`? – Eric Aug 28 '12 at 12:32
  • Your error is pretty descriptive – Hazem Salama Aug 28 '12 at 12:34
  • go to these stackoverflow links: - [access-control-allow-origin-not-allowed-by](http://stackoverflow.com/questions/9327218/access-control-allow-origin-not-allowed-by) - [origin-is-not-allowed-by-access-control-allow-origin](http://stackoverflow.com/questions/10143093/origin-is-not-allowed-by-access-control-allow-origin) - [jquery-xml-rest-access-control-allow-origin](http://stackoverflow.com/questions/4621056/jquery-xml-rest-access-control-allow-origin) - [xmlhttprequest-origin-null-is-not-allowed-access-control-access-allow-for-file](http://stackoverflow.com/questions/4208530/xmlhttprequest-o – Dariush Jafari Aug 28 '12 at 12:37

3 Answers3

0

You seem to be trying to access a URL from a server (192.168.10.106:8080) different from the one where the page is loaded from (localhost). This is called a cross-origin request and is blocked by most modern browsers. If you want to allow this request, the target server (192.168.10.106:8080) has to provide this information in its HTTP headers.

See http://en.wikipedia.org/wiki/Cross-origin_resource_sharing for more details

Please be aware that Internet Explorer 8 seems to block any requests from localhost to non-localhost even if the target server has the CORS headers. Therefore you may want to test the same thing on a non-localhost server or in a different browser.

chiccodoro
  • 14,407
  • 19
  • 87
  • 130
0

same origin policy does not allow you to do an ajax request to another domain/port/protocol
and vaadin application is not supposed to work like that
You can try embed the vaadin application in your php page with iframe

You can try this fiddle

hope_is_grim
  • 1,934
  • 15
  • 24
  • I had changed to localhost but I am still get same error – danarj Aug 28 '12 at 13:05
  • thank you for the answer. the vaadin application is a worker thread without a GUI or anything similar. how would the iframe solve the problem in this scenario ? – danarj Aug 29 '12 at 07:31
  • if it doesn't have any UI, why do you want to use Vaadin? and iframe still solve problem in this case, just don't let the iframe display (you can programmatically create an iframe on your event handler), the request will still be made. if it has to be ajax/xhr, you can send request to your vaadin application in one of your php pages, the ajax request will send request to that php page – hope_is_grim Aug 29 '12 at 07:52
0

/FTTBManager/ url is php page add

header('Access-Control-Allow-Origin: *');
yasaricli
  • 2,433
  • 21
  • 30