Clean uses of javascript to use json data for communication