# \[FMX04\] - Help with Loadvars and onLoad()

**URL:** <https://forum.kirupa.com/t/fmx04-help-with-loadvars-and-onload/216408>\
**Category:** flash\
**Created:** [February 16, 2007, 5:33am UTC](https://forum.kirupa.com/t/fmx04-help-with-loadvars-and-onload/216408 "2007-02-16T05:33:34Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mapes911](https://avatars.discourse-cdn.com/v4/letter/m/e68b1a/32.png) [@mapes911](https://forum.kirupa.com/u/mapes911)\
**Post date:** [February 16, 2007, 5:33am UTC](https://forum.kirupa.com/t/fmx04-help-with-loadvars-and-onload/216408/1 "2007-02-16T05:33:34Z")

</div>

Hello all,

I have the following code inside of an on(release) of a button (that is contained in a movieclip).

```
foundationReceiver = new LoadVars();
var phpCall = "http://XXXX.com/foundation.php?action=getList&foundation=" + this.foundationID;
foundationReceiver.sendAndLoad(phpCall, foundationReceiver);

foundationReceiver.onLoad = function(success) {
	if (!success) return;
	switch (this.action)
	{
             .....more code here....

```

Now, my problem is that the first time i click my button, it hits the sendAndLoad line, but does not enter the onLoad routine…  
If I click the button a second time, it DOES enter the onLoad routine… and everything is happy… BUT then it enters the onLoad routing AGAIN… without me clicking the button.

SO it does do the routine twice like it should… but it does it at the wrong time…

Can someone enlighten me on why this is? I am new to actionscript so please be gentle.

Thanks!
