Form request via $ .ajax returns only form elements

I am using AJAX to get a dynamic form on another page for security reasons. Ajax works fine, but the result displays the form elements and not the form tag

$.ajax('form.php?username='+username).done(function (data) {
     alert(data);
     $("#test").html(data);
})

      

The warning displays the whole form, including the form tag, with the appropriate attributes, but the form does not submit because the form tag is removed and when checking the code through firebug it found what I found

enter image description here

and this is the result of the warning (data)

enter image description here

I tried this, but it didn't insert the form tag at all

$("#test").html(data).promise().done(function(){
    $("#test").html.wrap('<form action="page.php">');
});

      

+3


source to share


1 answer


FORM cannot contain any other FORM, see Spec

The form

should not contain other form elements.



The browser engine strips out any nested FORM tags.

+1


source







All Articles