Posts

Showing posts with the label essential

wru, unit tests have ever been that easy

Do you remember my good old wru project ? It has been refactored , readapted for both client and server side environment such node.js and Rhino and, most important, it landed in github ;) Please spend few minutes to read the documentation and you'll realize why I chose this title for this post. Have fun with JavaScript Unit Tests!

All You Need for JSONP

I have just uploaded a truly simple, still robust, function able to do generic JSONP without pretending too much magic. The concept is simple, we pass the url, including the parameter name used to communicate the callback name, and a callback as second argument ... that's it, 202 216 bytes minified and gzipped ( many thanks @jdalton for the catch ) Here an example: <!-- the generic HTML page --> <script src="JSONP.js"></script> <script> this.onload = function () { var many = 0; JSONP("test.php?callback", function (a, b, c) { this.document.body.innerHTML += [ a, b, ++many, c ].join(" ") + "<br />"; }); JSONP("test.php?callback", function (a, b, c) { this.document.body.innerHTML += [ a, b, ++many, c ].join(" ") + "<br />"; }); }; </script> And here the testable demo result that should work with every bloody damned browser. What's on the server? No...