PHP json_encode and jQuery json

Ajax requests using jquery is pretty easy. All you have to do is to specify the URL for request, data sent along with the request, the data type returned, and the callback function. I choose datatype json because it’s much easier to modify with javascript. Here is the example:

Your PHP script, located at http://your/url/to/php/script/:

$array = array(
  'name' =>; 'alex',
  'fruit' =>; 'apple'
echo json_encode($array);

Your javascript Script, with jQuery supported:

  {your: data_to_send}, // ignore this for now
  function(returned_data) {
    //do something with the data returned
    console.log(; // will output 'alex'
    console.log(returned_data.fruit); // will output 'apple'

It won’t output anything on the page, but in the Javascript console instead. Firebug and Webkit-devtool users can see the console output using the “Inspect Element” tool. As far as I know, IE8-9 also has developer tools (press F12), as well as Opera Dragonfly.

HgIgnore for PyroCMS

PyroCMS bundle includes .gitignore file. But since I’m using TortoiseHg, I need to find an .hgignore equal for it. Here is what I translated from .gitignore:


Hope it’s useful for PyroCMS users who uses TortoiseHg. Enjoy!

[Linux] Setting Permissions on ntfs-3g Disks

If you’re originally a Windows user and going to migrate to Linux, you may still want to use your data formerly on your NTFS harddisk. This is my experience using Kubuntu 10.04, migrating from Windows XP. Please take note that the word ‘migrating’ here does not mean I delete my Windows OS. I’m just doing dual-boot. Continue reading “[Linux] Setting Permissions on ntfs-3g Disks”

Perceptions and Judgement

This is just a note summarizing a lecture. I found this topic interesting and useful, so I dig more.

As we’ve known well, humans make decisions by how they perceive, which is influenced by the events, people, and things around them. Generally humans cannot see something as a whole thing – they just know some part of it.

We don’t see things as they are, we see things as we are.
Continue reading “Perceptions and Judgement”