0

PHP-application has form loaded via AJAX as Bootstrp's Modal. This form sends as html

 type: 'post',
 dataType: 'html',
 data: $('#form-client').serialize(),
 cache: 'false',
 processData: 'false',

but the respond may be as html (when some fields have error and needed request again) and as json (when success). When respond is JSON I am unable get the properties of the respond. If I change dataType: 'html' to dataType: 'json' I am unable to get html page when error is occur (form validation).

What is the solution? Thanks.

vit
  • 55
  • 6
  • 2
    Why not just return html inside JSON like this: `"html" : "
    – Alex Lomia Apr 24 '16 at 18:24
  • Hmm. This is one of solutions – vit Apr 24 '16 at 18:25
  • 2
    You can also 1. try to parse JSON 2. catch the error if it was html 3. treat the field like html. This approach is described here http://stackoverflow.com/questions/20743326/jquery-ajax-returned-data-json-and-html-mix – Alex Lomia Apr 24 '16 at 18:29

0 Answers0