Restructure of JSON package, URL replacement params

Also fixed Ajax request to properly handle error response