问题描述
我正在使用jquery form.js上传文件.服务器端代码返回json格式的字符串,其中一个字段为"content". content字段具有HTML表单,我只需将其抓取并在div中的页面上吐出即可.
I'm doing a file upload using jquery form.js. The server side code returns a json formatted string, with one of the fields being "content". The content field has an HTML form, that I just grab and spit out on the page in a div.
这在Chrome和Firefox中可以正常运行,但在IE9中无法运行. IE9会删除所有打开的HTML标记.我整天都在搜寻Google,并尝试了很多事情,但我无法解决.
This works perfectly fine in Chrome and Firefox, but fails in IE9. IE9 strips all opening HTML tags. I've been googling all day long and tried a whole lot of things, but I can't fix it.
这是我的Jquery代码:
Here is my Jquery code:
$('#file_form').on("change", ".file_upload_field", function(ev) {
ev.preventDefault();
var options = {
url: '/ajax/process',
type: 'post',
dataType: 'json',
success: function(response) {
$('#upload-confirm').show().html(response.data.content);
}
};
$('#my-form').ajaxSubmit(options);
});
响应的结构如下
{
"success": true,
"message": "success",
"data": {
"content": "<form><input type=\"text\" /></form>"
}
}
推荐答案
您的响应不是有效的json,有效版本为
Your response is not valid json, a valid version would be
{
"success": true,
"message": "success",
"data": {
"content": "<form><input type=\"text\" /></form>"
}
}
这篇关于jQuery AjaxSubmit + json数据类型在IE9中剥离了HTML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!