function rate(id, rating) {
	var req = new JsHttpRequest();
    // Code automatically called on load finishing.
    req.onreadystatechange = function() {
        if (req.readyState == 4) {
            // Write result to page element (_RESULT become responseJS).
            document.getElementById('unit_long'+id+'').innerHTML = req.responseJS.text;
        }
    }
    // Prepare request object (automatically choose GET or POST).
    req.open(null, '/ajax.php', true);
    // Send data to backend.
    req.send( { photoid: id, rating: rating } );
}