dongze5043 2014-12-10 03:26
浏览 27

使用ajax使用echo与输出类CI的优点

I am currently polishing my program, but I notice that it's a bit slow because most of it are ajax requests. My question is that, are there any performance issues with regards to using echo over using CI output class when using ajax?

assume this is my ajax request:

$.post(base_url+'ajax')
  .done(function(res){
      res = JSON.parse(res);
      alert('res.message'); 
  });

when using ECHO:

<?php
  function ajax_response() { // inside my controller
      echo json_decode(array('message' => "Hello world"));         
  }
?>

when using CI output class:

<?php
  function ajax_response() { // inside my controller
       $this->output
        ->set_content_type('application/json')
        ->set_output(json_encode( array('message' => 'Hello world' ) ));       
  }
?>

I would truly appreciate your help. thanks!

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 Python报错怎么解决
    • ¥15 simulink如何调用DLL文件
    • ¥15 关于用pyqt6的项目开发该怎么把前段后端和业务层分离
    • ¥30 线性代数的问题,我真的忘了线代的知识了
    • ¥15 有谁能够把华为matebook e 高通骁龙850刷成安卓系统,或者安装安卓系统
    • ¥188 需要修改一个工具,懂得汇编的人来。
    • ¥15 livecharts wpf piechart 属性
    • ¥20 数学建模,尽量用matlab回答,论文格式
    • ¥15 昨天挂载了一下u盘,然后拔了
    • ¥30 win from 窗口最大最小化,控件放大缩小,闪烁问题