【问题标题】:Error : Resource interpreted as Document but transferred with MIME type application/json:错误:资源解释为文档,但使用 MIME 类型应用程序/json 传输:
【发布时间】:2017-03-27 06:44:40
【问题描述】:

通过 JSON 发送 3 个视图时出现以下错误

function BuscarOTPorId(){

        if('<?=$this->uri->segment(3);?>'){
            $.ajax({
                type: "POST",
                url: "<?= base_url()?>AgregarOTController/BuscarOTPorId/"+'<?=$this->uri->segment(3);?>',
                data: "",
                success: function(objView){

                }    
            });

    }
}

控制器

public function BuscarOTPorId(){
    $id_ot        =$this->uri->segment('3');
    $getOT        =$this->MainModel->BuscarOTPorId($id_ot);

    $data = array();
    $toJson = array(
    'success' => 'true',
    'ViewSet' => array(),
    'getOT'=>$getOT
    );
    $toJson['ViewSet']['header']    = $this->load->view('Header/header', $data, true);
    $toJson['ViewSet']['leftpanel'] = $this->load->view('leftpanel/leftpanel', $data, true);
    $toJson['ViewSet']['create']    = $this->load->view('OT/AgregarOT2', $data, true);

    $this->output
        ->set_content_type('application/json')
        ->set_output(json_encode($toJson));
}

错误控制台 Chrome

资源解释为文档,但使用 MIME 类型 application/json 传输:“http://localhost/AgregarOTController/BuscarOTPorId/99”。

【问题讨论】:

    标签: json ajax codeigniter


    【解决方案1】:

    在您的请求标头中,您发送了 Content-Type: text/html,这意味着您希望将响应解释为 HTML。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-01-30
      • 2012-12-08
      • 2011-04-23
      • 2021-04-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-03-19
      相关资源
      最近更新 更多