jQuery Html加载剥离<form>标记

时间:2016-04-12 21:26:58

标签: javascript jquery ajax asp.net-mvc partial-views

我通过ajax调用html()加载局部视图。我可以在Chrome javascript调试中看到response标记<form>。但当它加载到源时,它正在消失。除了标签,我可以使用其他html。

我正在另一个标签下加载。我不知道这里有什么问题?

var HandleGetEditPhone = function (response) {

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

}

2 个答案:

答案 0 :(得分:5)

您应该检查是否嵌套表单元素,因为chrome会删除嵌套的表单标记。

与您的问题相关:

Chrome removes form element when using jQuery ajax

How do you overcome the html form nesting limitation?

答案 1 :(得分:0)

我遇到了同样的问题。以下代码段对我有用。

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

请告知它是否可以解决您的问题。