Popup
This scripts show the content of a div when clicked on an opener.
Labels: javascript
jQuery - Extend tablesorter plugin
This js code extends the tablesorter plugin in jQuery:
- Parser for sorting values like "$1,300.50"
- Parser for sorting values like "2 months ago","3 years ago" (actual timestamp hide in the comment)
- Parser for sorting values like "SMALLER","SMALL" (actual text value hide in comment)
- Widget to highlight a row when mouse hovers it
- Widget to highlight a header when mouse hovers it
- Widget to save/memorize sort order via AJAX
Labels: javascript, jquery
JSON with Padding = JSONP
With JSONP, you can avoid the "Access is Denied" problem when loading a remote AJAX request. jQuery 1.2.x now supports JSONP, you can use that or this simple code snippet. In this example, let's assume you're on a page with a remote javascript loaded, now you only want this remote script to reload, not the whole page.
And the result of getJSON.php:
Labels: ajax, code, javascript
Reloading partial page content with JavaScript
If you need to reload a partial content (not the whole page) with JavaScript, you can easily use AJAX (jQuery is the simplest). But if the content is also from another website (eg: some API), then you can use JSONP (JSON with Padding) to get around the security protection of AJAX requests.
And in the server-side javascript.php, you would return:
Labels: javascript