LoadVars Variable Return Problem?

Post here your questions about Actionscript and Java server side extensions development.

Moderators: Lapo, Bax

User avatar
coolboy714cp
Posts: 323
Joined: 06 Feb 2010, 02:45
Contact:

LoadVars Variable Return Problem?

Postby coolboy714cp » 01 May 2011, 16:02

In my extension, I'm loading a variable called iM to my extension from a PHP page, so I'm using LoadVars on the server.

What would be the best way to return the iM variable, and where would I put the coding at?

Code: Select all

...
function lV(urlToLoad, targetUser) {
   var _send = new LoadVars()
   var _load = new LoadVars()
   
   // Set parameters to send
   _send.mN = String(targetUser);
   
   // Handle the remote data
   _load.onLoad = function(success, errorMsg)
   {
      if (success)
      {
         trace("Data received:")
         
         trace("iM    : " + this.iM)
         iM = this.iM;
         trace("iM 1 = " + iM);
         return iM;
      }
      else
      {
         trace("Loadvar Failed. " + errorMsg)
      }
   }
   
   // Send data with POST method and receive it back in the _load object
   _send.sendAndLoad(urlToLoad, _load, "post")
}
...


The reason I'm asking this is because currently, the return code isn't working, although when I trace the variable it traces out correctly.

The return code I'm currently using in the coding above comes out to undefined, rather than the correct value that is being traced.

Does anyone know why and/or how to fix it?
User avatar
BigFIsh
Posts: 1698
Joined: 25 Feb 2008, 19:26
Location: New Zealand

Postby BigFIsh » 02 May 2011, 02:20

Smartfox's forum is my daily newspaper.
User avatar
coolboy714cp
Posts: 323
Joined: 06 Feb 2010, 02:45
Contact:

Postby coolboy714cp » 02 May 2011, 02:31

I just setup my crossdomain on my webhost, and it is still returning undefined. - http://mechmicecheats.org/crossdomain.xml
User avatar
BigFIsh
Posts: 1698
Joined: 25 Feb 2008, 19:26
Location: New Zealand

Postby BigFIsh » 02 May 2011, 04:12

Can you show us how you're sending the data back to your extension from php?
Smartfox's forum is my daily newspaper.
User avatar
coolboy714cp
Posts: 323
Joined: 06 Feb 2010, 02:45
Contact:

Postby coolboy714cp » 02 May 2011, 04:28

Code: Select all

<?php
$var = $_POST["mN"];

$con = @mysql_connect("localhost", "dbadmin1", "*password*") or die("");

if ($con) {
   @mysql_select_db("testdb1", $con);
   $query = @mysql_query("SELECT * FROM testTable WHERE username='$var' LIMIT 1;", $con);
   $res = @mysql_fetch_assoc($query);
   $resIM = $res["ismember"];
   if ($res["username"] == $var) {
      print "&iM=$resIM&mN=$var";
   } else {
      print "&iM=false&mN=$var";
   }
} else {
   print "&iM=false&mN=$var";
}
?>


I'm just using a regular PHP code to print out the variables.
User avatar
BigFIsh
Posts: 1698
Joined: 25 Feb 2008, 19:26
Location: New Zealand

Postby BigFIsh » 02 May 2011, 06:21

The php looks alright to me.

Looking at your sendAndLoad code, you appear to have two LoadVars. I think you should only need one.

Have you tried the example provided in http://forums.adobe.com/message/2659798#2659798?
Smartfox's forum is my daily newspaper.
User avatar
coolboy714cp
Posts: 323
Joined: 06 Feb 2010, 02:45
Contact:

Postby coolboy714cp » 02 May 2011, 18:04

Alright, I will try to do that after I setup my server. But the coding I posted above in my extension was from the loadVarsTest.as example file.

Return to “Server Side Extension Development”

Who is online

Users browsing this forum: No registered users and 39 guests