# sendAndLoad?

**URL:** https://forum.kirupa.com/t/sendandload/21102
**Category:** Uncategorized
**Created:** [May 17, 2003, 3:16am UTC](https://forum.kirupa.com/t/sendandload/21102 "2003-05-17T03:16:01Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![markw](https://avatars.discourse-cdn.com/v4/letter/m/53a042/32.png) [@markw](https://forum.kirupa.com/u/markw)
#### Post date: [May 17, 2003, 3:16am UTC](https://forum.kirupa.com/t/sendandload/21102/1 "2003-05-17T03:16:01Z")

</div>

What is the correct way to refer to variables returned in a sendAndLoad operation? Php is returning a name=value& string which is being passed back into a LoadVars object called rtnVars. How should I then refer to the values to update the value of a text field?  
Thanks  
Mark  
:-\

---

<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: [May 17, 2003, 9:20am UTC](https://forum.kirupa.com/t/sendandload/21102/2 "2003-05-17T09:20:54Z")

</div>

well, it loads it back into the LoadVars object (unless you specified another object to load it to)  
anyways, to refer to it simply use myLoadVars.name, i.e:

```auto
myTextField.text = myLoadVars.name;

```

---

<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: [May 17, 2003, 2:24pm UTC](https://forum.kirupa.com/t/sendandload/21102/3 "2003-05-17T14:24:33Z")

</div>

Well that is what I thought but I can’t populate the text field. In this example I have used a different LoadVars object to receive the reply. My php script returns simply lastName=Smith. I’ve tested this in a browser.

Here’s the actionscript:-

// ActionScript Document  
function dataLoad(){  
//will post data eventually but not for testing  
lvAddressData.sendAndLoad(“hotels.php”, rtnVars, “POST”);  
myTextField.text = rtnVars.lastName  
}

//Run starts here  
lvAddressData = new LoadVars();  
rtnVars = new LoadVars();  
dataLoad()

The text field has an instance name of myTextField. Should this be variable name instead. I have seen both methods mentioned. What is the difference?

Thanks, Mark

---

<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: [May 17, 2003, 2:36pm UTC](https://forum.kirupa.com/t/sendandload/21102/4 "2003-05-17T14:36:54Z")

</div>

ahh, you need to wait for the data to actually load before you can populate it. something like this:

```auto
function dataLoad() {
  lvAddressData.onLoad = dataRecieved;
  lvAddressData.sendAndLoad("hotels.php", rtnVars, "POST");
}
function dataRecieved(success) {
  if (success) {
    myTextField.text = rtnVars.lastName;
  } else trace("Failed!");
}
lvAddressData = new LoadVars();
rtnVars = new LoadVars();
dataLoad();

```

---

<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: [May 17, 2003, 3:47pm UTC](https://forum.kirupa.com/t/sendandload/21102/5 "2003-05-17T15:47:42Z")

</div>

I think we are getting somewhere, but I get the “Failed” trace.

My text field is set up as Dynamic Text and has instance name of myTextField. My php script returns lastName=Smith  
Any more ideas?

---

<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: [May 17, 2003, 3:49pm UTC](https://forum.kirupa.com/t/sendandload/21102/6 "2003-05-17T15:49:33Z")

</div>

What is the “success” passed to dataReceived??

---

<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: [May 18, 2003, 3:36pm UTC](https://forum.kirupa.com/t/sendandload/21102/7 "2003-05-18T15:36:24Z")

</div>

from the AS Dictionary:

> Usage

myLoadVars.onLoad(success)

Parameters

success The parameter indicates whether the load operation ended in success (true) or failure (false).

for some reason its failing to send/load the data. im not sure why.

---

<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: [May 18, 2003, 8:01pm UTC](https://forum.kirupa.com/t/sendandload/21102/8 "2003-05-18T20:01:42Z")

</div>

Should my text field have an instance name or variable name??

---

<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: [May 18, 2003, 9:06pm UTC](https://forum.kirupa.com/t/sendandload/21102/9 "2003-05-18T21:06:20Z")

</div>

well, using this code, instance name.

but that shouldn’t cause the LoadVars object to fail! try removing that ‘if’ and see if that works. make sure the URL you’re accessing actually works, and stuff like that.
