Tuesday, January 19, 2010

jQuery jsonp support

It's still not supporting the error handling in 1.4 for jsonp request.

some useful links:
http://remysharp.com/2007/10/08/what-is-jsonp/
http://www.ibm.com/developerworks/library/wa-aj-jsonp1/?ca=dgr-jw64JSONP-jQuery&S_TACT=105AGY46&S_CMP=grsitejw64

Thursday, January 7, 2010

Javascript Closure to remember variable in context

Closure can be used to remember variable in the context. e.g.
<script>
$().ready(function() {
var ts = $('.t');
for(var i = 0; i < ts.length; i++) {
var onClick = function(i) {
return function() {
alert(i);
return false;
}
}
$(ts.get(i)).bind('click', onClick(i));
}
});
</script>
<body>
<p><a class='t' href=''>Google</a></p>
<p><a class='t' href=''>Yahoo</a></p>
</body>

Member Not Found in IE when accessing event in callback

http://javascriptfixer.com/member-not-found.php

I spent a couple of hours trying to fix it and finally I found the same solution as the article above mentioned. In my case, the function is from an ajax onSuccess callback.