I have a form that gets submitted to the server via jQuery .ajax()
POST. If the form passed the validation on the server-side, the server would return result in HTML for the client-end to update its presentation accordingly. If, however, the form failed the validation, the server would return result in JSON, which consists of the validation errors.
两种结果将在<代码>.ajax(
)。 由于这两种类型都是可能的,手工艺者需要一种方法来确定其结果是否为超文本或初才。 我如何能够这样做?
Note: On the surface, my question looks like the same as this existing SO question but they are not the same. In that question, there s only one possible datatype (HTML or JSON), while my problem is about finding a way to deal with two possible datatypes (HTML and JSON).