developer documentation r21357

fm.util

The fm.util package contains utility methods that are used by the various other packages.

fm.util.escapeHTML(str)

This function takes a string, and encodes <, > and & into &lt;, &gt; and &amp;

fm.util.getXMLHTTPRequest()

This function is used to retrieve an XMLHTTPRequest object. Various browsers have a different way to obtain this, so using this function you'll always get the correct one.

Example

var request = fm.util.getXMLHTTPRequest();

fm.util.log(message)

This function is a wrapper around console.log (implemented by for example Firebug). The difference is that this function will not throw an error if no such debugging tool is installed.

Example

fm.util.log('Hello world');

fm.util.toJSON(data)

This function can be used to transform any javascript variable to a json variable.

Example

var myArray = [1,2,3,4]; myArray.push(5); document.write(fm.util.toJSON(myArray)); // Outputs '[1,2,3,4,5]' without the quotes

fm.util.toQueryString(data)

This function takes an object, and transforms it to a query string

var myData = { prop1 : 'value1', prop2 : 'value2' } document.write(fm.util.toQueryString(myData)); // Outputs 'prop1=value1&prop2=value2'
<< 9.3 fm.flash 9.5 fm.geolocation >>