Tweaked javascript, creacreated json output with ajax call