IE tries to download json response while submitting jQuery multipart form data containing file

后端 未结 9 653
别那么骄傲
别那么骄傲 2020-12-14 15:03

I\'m trying to submit a form with a file field in it via jQuery.Form plugin, here\'s the code:

$(\'form\').ajaxSubmit({
  url: \"/path\",
  data         


        
相关标签:
9条回答
  • 2020-12-14 15:23

    I came up with the following workaround (in Zend Framework):

    if (!$this->_request->isXmlHttpRequest()) {
        die('<textarea>'.Zend_Json::encode($data).'</textarea>');
    }
    $this->view->assign($data);
    
    0 讨论(0)
  • 2020-12-14 15:30

    Just set Content-Type: text/html

    This happens because IE8 doesn't recognize application/... mimetype. This works for me.

    Hope it helps.

    0 讨论(0)
  • 2020-12-14 15:32

    if you work with Zend you can do

    $this->getResponse()->setHeader('Content-Type', 'text/html');
    

    in your controller action. and on client-side, in case of jQuery, you can do

    data = $.parseJSON(data);
    
    0 讨论(0)
提交回复
热议问题