View Full Version : load()
Henxon
September 2nd, 2005, 03:31 AM
Hello
I try to use load("php/file.php") but that doesnt work, I have to use load("http://www.myaddress.com/php/file.php") . Must it be that way?
//henxon
mlk
September 2nd, 2005, 04:42 AM
try load("./php/file.php")
the hell's the 'load()' function anyway ?
icio
September 2nd, 2005, 06:13 AM
i think you've gotten confused with this function's actual use. what are you trying to use load for ?
if you're trying to load a new browser page, try using the `getURL` function like this:
getURL("http://www.kirupa.com", "_blank");
if you're trying to load a file's html into a text field, try something like this:
var xmlLoader:XML = new XML();
var xmlLoader.onLoad = function(success) {
if (!success) { return; }
trace(_root.xmlLoader.toString());
}
xmlLoader.load("file.txt");
hope this helps :thumb:
Henxon
September 2nd, 2005, 06:20 AM
Explenation time :thumb:
This is the code:
lvProducers = new LoadVars();
lvProducers.load("./img/producers.php");
lvProducers.onLoad = function(success) {
if (success) {
producersArray = this.imgList.split(", ");
}
else {trace("could not load file"); }
}
This code reads a php file - producers.php, see below - that creates an array of all files that lies in a folder... The code works when I use "http://www.blabla.com/img/producers.php", but not as shown above... How come?
<?php
$dir = opendir("producers/");
while ($file = readdir($dir)) {
if ($file=="." or $file=="..") continue;
$string.= $file;
$string.= ", ";
}
echo "imgList=".$string;
?>
icio
September 2nd, 2005, 06:30 AM
the problem is probably that the file is loading before the `onLoad` function of the LoadVars object can be set and called.
rearrange your code like this:
lvProducers = new LoadVars();
lvProducers.onLoad = function(success) {
if (success) {
producersArray = this.imgList.split(", ");
}
else {trace("could not load file"); }
}
lvProducers.load("./img/producers.php");
Henxon
September 2nd, 2005, 06:50 AM
I have changed to your code now, because I have had some strange problems with the php usage on my site. Allthough, I can't see that that's the cause of the fullpath address problem, since the code works with the full address "http://www...." , but not with the "./img/" !
//Henxon
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.