views:

99

answers:

2

Hi,

i have a php file on the server, it just prints random numbers.

And i want to get this numbers by using XMLHttpRequest from another domain.

how can i do this?

thanks

+1  A: 

You can't.

XHR is subject to the same origin policy. There is ongoing work to design and implement systems to allow cross-domain XHR, but the current state of those (the lack of browser support in particular) make it impractical for any real project.

The usual method to work around this is to implement the system using JSON-P instead of XHR.

David Dorward
i guess google chrome extensions allow cross-domain with the permission command as i want to send request from html file working in google chrome.
Ahmet vardar
yeah, I agree with David - JSONP, iframe or CSS hacks, or a proxy page (proxy.php?url=http://someurl) and then handler code on the .php side.
Dan Beam