Jquery AjaxSubmit + json datatype stripped HTML in IE9

心已入冬 提交于 2020-01-16 07:54:40

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!