added a new function for ajax and json