Codeigniter和Jtable插件 - 与服务器通信时出错 [英] Codeigniter and Jtable plugin - An error occured while communicating to the server

查看:127
本文介绍了Codeigniter和Jtable插件 - 与服务器通信时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有2个php文件,将生成一个jtable插件,当我运行没有使用代码igniter完美地工作。但是当我把它放在codeigniter这是错误会显示的时间。这是我的文件层次结构

  application / 
...
views /
system_admin /
PersonActions.php
view_systemadmin_manageprojects.php

当我运行它时,



我在调用其他php文件的视图文件中有这个代码

 < script type =text / javascript> 

$(document).ready(function(){

//准备jTable
$('#PeopleTableContainer')。jtable({
title:'Table of News and Events',
actions:{
listAction:'PersonActions.php?action = list',
createAction:'PersonActions.php?action = create',
updateAction:'PersonActions.php?action = update',
deleteAction:'PersonActions.php?action = delete'
},
 类PersonActions extends CI_Controller {

function listRecord(){

}

function create(){

}

函数更新){

}

function delete(){

}

}

现在javascript

  //准备jTable 

var base_url =<?= base_url()?>; // in your html as global before call jtable script

$('#PeopleTableContainer')。jtable({
title:'Table of News and Events',
actions: {
listAction:base_url +'PersonActions / list',
createAction:base_url +'PersonActions / create',
updateAction:base_url +'PersonActions / update',
deleteAction:base_url +'PersonActions /删除'
},


I have 2 php files that will generate a jtable plugin which when I run without using code igniter works perfectly. But when I put it in codeigniter that's the time the error will show up. here is my file hierarchy

 application/
      ...
      views/
           system_admin/
                 PersonActions.php
                 view_systemadmin_manageprojects.php

When I run it, the base interface of jtable shows up but without a data plus an error.

I have this code in the view file which calls the other php file

<script type="text/javascript">

    $(document).ready(function () {

        //Prepare jTable
        $('#PeopleTableContainer').jtable({
            title: 'Table of News and Events',
            actions: {
                listAction: 'PersonActions.php?action=list',
                createAction: 'PersonActions.php?action=create',
                updateAction: 'PersonActions.php?action=update',
                deleteAction: 'PersonActions.php?action=delete'
            },

解决方案

CI framework use MVC (Model, View, Controller) pattern and you have to follow it, here you are sending requests direct to PHP PersonActions class, try to create controller with name personAction and call your actions

class PersonActions extends CI_Controller{

   function listRecord(){

   }

   function create(){

   }  

   function update(){

   }

   function delete(){

   } 

}

now javascript

//Prepare jTable

var base_url = "<?=base_url()?>"; // in you html as global before calling jtable script 

$('#PeopleTableContainer').jtable({
    title: 'Table of News and Events',
    actions: {
        listAction: base_url+'PersonActions/list',
        createAction: base_url+'PersonActions/create',
        updateAction: base_url+'PersonActions/update',
        deleteAction: base_url+'PersonActions/delete'
    },

这篇关于Codeigniter和Jtable插件 - 与服务器通信时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆