I have the problem.
I send ajax request as dateType: json, and get HTML code, paste it as $(selector).html(res.html), and browser don't understand attr required="required" and type="email", does not works.
Only if I change dateType on HTML it works.
How can I make it work?
$.ajax({
dataType: "json",
success: function (res) {
$("#html").html(res.html);
}
})
res:
{"status": true, "html": "<form id=\"ajax-form\"><input type=\"email\" name=\"email\" required=\"required\" /></form>"}
Your HTML works fine. The
<input>
has all the attributes on it that it should. The problem is that your submit button is in the wrong spot. It needs to be inside the form.Do that, then it works fine. So, basically make your JSON:
DEMO: http://jsfiddle.net/6a2Ja/3/