fixed sending json back to an HTML ajax request, and just send the snippet if it is an HTML ajax request