4

I am loading partial view through ajax call html(). I can see response has <form> tag in chrome javascript debug. But when it loads to source it is disappearing. I can rest of the html except tag.

I am loading under another tag. I don't know what is the issue here?

var HandleGetEditPhone = function (response) {

if (response !== "") {
    $('#DivPhoneContainer').html(response);
}

}

James123
  • 11,184
  • 66
  • 189
  • 343

2 Answers2

6

You should check if you are nesting form elements, since chrome removes nested form tags.

related to your question:

Chrome removes form element when using jQuery ajax

How do you overcome the html form nesting limitation?

Community
  • 1
  • 1
Alfonso
  • 159
  • 4
  • Thank you, this was my issue. I had a modal form that ended up being inside another form. Chrome was stripping the form tags out (seemingly magically / for no reason). Needed to move the modal form outside the main form. – Greg Blass Nov 05 '16 at 22:32
  • I had this issue and it was caused by an unclosed form tag further up the page. – Jack Aug 07 '17 at 12:00
  • Why is it not removed in jQuery 1.6 and works just fine, but 1.7 removes it. – Antony D'Andrea May 17 '18 at 08:14
1

I faced the same issue. The following snippet worked for me.

var HandleGetEditPhone = function (response) {
    if (response !== "") {
        $('#DivPhoneContainer').empty();
        $('#DivPhoneContainer').html($(response));
    }
}

Do let know if it solves your issue.

Prashant Nair
  • 306
  • 3
  • 9
  • This generally happens when using an AJAX response of HTML data. This answer should be selected as the best answer. – Matt Jan 06 '20 at 09:31