问题
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.
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.
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);
});
Response is structed like this
{
"success": true,
"message": "success",
"data": {
"content": "<form><input type=\"text\" /></form>"
}
}
回答1:
Your response is not valid json, a valid version would be
{
"success": true,
"message": "success",
"data": {
"content": "<form><input type=\"text\" /></form>"
}
}
来源:https://stackoverflow.com/questions/15650062/jquery-ajaxsubmit-json-datatype-stripped-html-in-ie9