Error function alone working in AJAX JQUERY