# Communicating to cgi on a different domain/ server

**URL:** <https://forum.kirupa.com/t/communicating-to-cgi-on-a-different-domain-server/57701>\
**Category:** flash\
**Created:** [July 15, 2004, 1:15pm UTC](https://forum.kirupa.com/t/communicating-to-cgi-on-a-different-domain-server/57701 "2004-07-15T13:15:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![winstun](https://avatars.discourse-cdn.com/v4/letter/w/a183cd/32.png) [@winstun](https://forum.kirupa.com/u/winstun)\
**Post date:** [July 15, 2004, 1:15pm UTC](https://forum.kirupa.com/t/communicating-to-cgi-on-a-different-domain-server/57701/1 "2004-07-15T13:15:42Z")

</div>

G’day all!

I’ve never attempted this before and would appreciate some advice on connecting to server-side scripts at a different domain.

For example, on one domain would be the main site with all the .swf’s, but the database containing the relative information is on a different domain and the two need to communicate with each other.

Would I use the LocalConnection object or if possible, could someone post an example to connect to a .php file on a different server than the .swf that is calling it.

The main issue why I’m asking is the main site server is nt with asp and I need to call a php file to connect to a database whereby both are on a \*nix server.

Any assistance would be helpful, thanks.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 15, 2004, 2:52pm UTC](https://forum.kirupa.com/t/communicating-to-cgi-on-a-different-domain-server/57701/2 "2004-07-15T14:52:14Z")

</div>

So I’ve tried the following code:

```auto

var my_lv = new LoadVars();
 my_lv.onData = function(src) {
  if(src==undefined){
   output_txt.text = "Unable to connect to server!";
  }else{
   output_text.text = src;
  }
 }
 my_lv.load("http://www.mydomain.com/returnData.php?foo=iamdata");

```

When I test this I get my custom error msg because there was no data loaded.  
I’ve even put a crossdomain.xml file where the .swf is stored to accept the domain where the test php script is stored.

Can anyone give me a hand?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 15, 2004, 3:19pm UTC](https://forum.kirupa.com/t/communicating-to-cgi-on-a-different-domain-server/57701/3 "2004-07-15T15:19:14Z")

</div>

I’ve modified it to test locally ( see below ) and it works but if I try to access the exact same script on a different domain it returns ‘undefined’.

```auto

var my_lv = new LoadVars();
my_lv.onLoad = function() {
  _root.output_txt.text = my_lv.foo;
 }
}
my_lv.load("http://localhost/returnData.php?foo=iamdata");

```
