I wouldn't recommend 4chan's buggy and broken code. Instead, try something new. pychan is a very light, completely AJAX-powered imageboard written in ~150 lines of Python and ~450 lines of JavaScript. All requests return JSON (like thread listing, thread display, etc.). If you are wanting to play around a little with a new imageboard, this is probably better for you.
Browse source:
http://azabani.com/cgit.cgi/pychan
Clone source: git://azabani.com/pychan
Reference implementation:
http://neckbeardchan.azabani.com/