Rich Rodecker’s blog on flash, flex, actionscript, javascript, and php, with a dash of randomness
LoadVars for Javascript
I put together this LoadVars class for javascript for users who would rather deal with the flash LoadVars object than the XMLHttpRequest object (this LoadVars class is pretty much just a wrapper for that object). It’s quick and dirty but it works.
A few notes about the class:
¥ all requests use GET. the send and sendAndLoad methods will automatically convert the properties of the LV object to a query string and append it to the URL.
¥ You dont need to escape the return value coming back to the LV object. You can send a plain string if you like. However, you can set the LoadVars.parseVarString to true, and you can pass in a string like “myVar=This is the ver&myvar2=This is the secondvar.” You don’t need to encode the string, but if you do it will decode it.
¥ the return value is always accepted by the same LV object. In flash, you can specify a target object..that is not used here.
¥ only string or number datatypes may be used.
¥ getBytesLoaded/getBytesTotal aren’t implemented.
¥ there is a LoadVars.onLoadError method you can use to handle situations such as document not found.
You can test it out here.
You can grab the source files here.
Posted by flashape at 05:05 PM | Comments (1)
| Print article | This entry was posted by flashape on April 22, 2005 at 1:14 pm, and is filed under DOM/Javascript. Follow any responses to this post through RSS 2.0. You can leave a response or trackback from your own site. |
about 1 year ago
Your font is horrible.