Chrome浏览器使用jQuery阿贾克斯时删除表单元素 [英] Chrome removes form element when using jQuery ajax

查看:313
本文介绍了Chrome浏览器使用jQuery阿贾克斯时删除表单元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从一个动作一个JSON响应返回一些简单的HTML标记。

I am returning some simple HTML markup in a JSON response from an action.

下面是完整的响应(增加了可读性换行):

Here is the full response (linebreaks added for readability):

    {
        "Success":true,
        "Content":"\r\n
<div class=\"editor-form\">\r\n

<form action=\"/Blah/Blah/5104?id=9\" method=\"post\">

<input data-val=\"true\" data-val-number=\"The field Id must be a number.\" data-val-required=\"The Id field is required.\" id=\"Id\" name=\"Id\" type=\"hidden\" value=\"5104\" />

<input data-val=\"true\" data-val-number=\"The field Vat Rate must be a number.\" data-val-required=\"The Vat Rate field is required.\" id=\"VatRate\" name=\"VatRate\" type=\"hidden\" value=\"1.2000\" />

<div class=\"display-field\">\r\n\t

<label for=\"Price\">Price (Ex-VAT)</label>\r\n\t

<input class=\"text-box single-line\" data-val=\"true\" data-val-number=\"The field Price must be a number.\" data-val-required=\"The Price field is required.\" id=\"Price\" name=\"Price\" type=\"text\" value=\"92.50\" />\r\n\t

</div>\r\n

</form>
</div>",
"Data":null,
"Errors":null
}

下面是我用它做一个成功的响应之后:

Here is what I do with it after a succesful response:

$("#EditPriceDialog").html(data.Content).dialog(MyProject.UI.DialogOptions({ minWidth:380, minHeight:200, modal:true }))

在标记呈现,表单元素缺失。表格中的元素仍然存在。这只发生在Chrome。在IE9和FF 19表单元素是存在的。什么在Chrome的不同?

When the markup renders, the form element is missing. Elements inside the form are still there. This only happens in Chrome. In IE9 and FF 19 the form element is there. What's different in Chrome?

推荐答案

铬删除表单元素,如果它已经被其他表单元素所包围。此外,ASP.NET的呈现所有网页的IT服务器的形式标记,因此Chrome的剥离在data.Content的形式标记。我不认为IE或Firefox的行为这种方式。

Chrome removes form element if it is already surrounded by another form element. Also, ASP .Net renders form tag for all pages it servers, as a result Chrome is stripping off the form tag in data.Content. I don't think IE or firefox behaves this way.

编辑:希望你会发现这个很有用,<一个href=\"http://stackoverflow.com/questions/597596/how-do-you-overcome-the-html-form-nesting-limitation\">How你克服了HTML表格嵌套限制

Hope you will find this useful, How do you overcome the html form nesting limitation

这篇关于Chrome浏览器使用jQuery阿贾克斯时删除表单元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆