Code improvement by using ajax, jquery and json.