- use the latest jQuery
- Caching Selections (assign it to a variable)
- Caching Other Items
- Use element properties (DOM) when possible (instead of jQuery properties)
Showing posts with label jQuery. Show all posts
Showing posts with label jQuery. Show all posts
Tuesday, 5 February 2013
jQuery General Performance Tips
Monday, 4 February 2013
jQuery Type Testing Functions
- Determine the type of an object
- Useful for optional parameters & validation
Functions:
- $.isArray(array)
- $.isFunction(function) - another way to do this ( if (typeof <functionName> == "function")
- $.isEmptyObject(object)
- $.isPlainObject(object)
- $.isXmlDoc(doc)
- $.isNumeric(number)
- $.isWindow(window)
- $.type(object)
Return Values:
- boolean
- number
- string
- function
- array
- date
- regexp
- object
- undefined
- null
Turn javascript object into a string
use json2.js from http://www.JSON.org/json2.js
e.g.
<script src="json2.js"></script>
...
JSON.stringify( {
FirstName: $('#FirstName').val(),
LastName: $('#LastName').val()
});
To turn a JSON string into javascript ojbect, use parseJSON.
var json = '{"fname" : "john", "lname" : "smith", "age" : 35}';
var jsObject = $.parseJSON(json);
e.g.
<script src="json2.js"></script>
...
JSON.stringify( {
FirstName: $('#FirstName').val(),
LastName: $('#LastName').val()
});
To turn a JSON string into javascript ojbect, use parseJSON.
var json = '{"fname" : "john", "lname" : "smith", "age" : 35}';
var jsObject = $.parseJSON(json);
Friday, 13 January 2012
Ways to display XML data on browser
- Open the xml file from IE
- Open XML file from IE using XSL
- Use jQuery to load the whole XML file into a container
- Use jQuery to parse the XML file into a container
- Display the XML file (with/without XSL) in an iframe tag of the HTML file
e.g. <iframe src="test.xml" scrolling="no" frameborder="0"></iframe>
Subscribe to:
Posts (Atom)