Archive for June 2009
Google VS PHP
Here is the recent article Google published for Web optimisation technique for PHP. It got bad PHP community slap back especially from the Sitepoint.com and Google group forum. It is quiet interesting to see how beginner PHP will actually fall in the trap which recomemded so of the tips from the articles.
JQuery get $.getJSON data
Imagine you have server side data return to your Javascript client side.
1: var groupid = null;
2:
3: $.getJSON(url, data,
4: function(result){
5:
6: groupid = result.groupid;
7: //do whatehever you like here
8:
9: // you wanted to return the data that you have been parsed or assign
10: }
11: );
12:
13: alert(groupid ); //error : will return null
So instead of that, we need to use delegate or callback function that JQuery have provided to us. Remember the $.fn. thing.
Now let see how we can use the delegate function to return us the data:
1: $.getJSON(path + "?request=url.here",
2: function (data)
3: {
4: var selectOption = '';
5:
6: //do what ever you like with the json data
7: selectOption = selectOption + "testing" + data; //example only
8: $.fn.delegateJSONResult(selectOption );
9: });
10:
11: $.fn.delegateJSONResult = function(data) {
12: alert(data);
13: }

Spread Firefox
