FightSkillz.com - Life, Code, & Idiocy
KaTG book:What Do We Do Now? is in stores! pick it up at your local book store. doing so keeps the book available in stores. katg.com/book 13 hrs ago

Posts Tagged ‘Code’

Mootools 1.2 – Update any element with Ajax

Sunday, May 18th, 2008
Easily update any element's inner html with an ajax get request. Simple get request
$('div_files').load('getfiles.php');
What it does is get the content of getfiles.php and uses it as the innerHtml for the div with id
'div_files'
Slightly more complex get request
var myHTMLRequest = new Request.HTML({url:'getfiles.php', update:'div_files'}).get({'user_id': 25});
In this get request, like the simple one you specify the location of the server side script, which happens to be in the same directory, and you specify the element who's innerHtml you want to update. After the
.get
you send a variable to the server, in this case
user_id
with the value 25. Note: In the php file you'll need to use a
$_GET['user_id']
instead of
$_POST

Downloading a File with Flex 3

Sunday, May 18th, 2008
I stumbled over this when I was building the CCMCP Library app but I suppose history's due to repeat itself. The problem is this: downloading a file from flex just doesn't work; A dialogue pops up, you choose a place to save the file, but when you hit save no file gets downloaded. If you're sure the url is correct and you haven't made any syntax errors, then the most likely cause is that you've declared the
'fileRef'
variable within the
'download();'
function. The following code will work.
private var fileRef:FileReference = new FileReference();
 
public function download():void
{
fileRef.download(new URLRequest('http://web-site/file-name'), 'simple filename');
}
The problem's also documented at Adobe and Lynch Consulting