web-设计 发表于 2013-1-13 18:50:23

请教一个关于ci和ajax得问题~~~


目录:

127.0.0.1/ci/
                   application\controllers\test.php
                   application\views\test_v.php
                   js\script\test_j.js


在test_v.php中 引入了test_j.js文件

test_j.js中是jquery得ajax代码:
var dataString = 'name=1&email=2&phone=3';
                $.ajax({
                        type:    'post',
                        url:   '/index.php/test/check',
                        data:    dataString,
                        dataType:'text',
                        success:function(msg){
                                  
                        },
                        error:function(){
                                alert("错误");
                        }
                })

test.php:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Test extends CI_Controller
{
        public function index()
        {
                $this->load->view('test_v');
        }

        public function check()
        {
                $name = $_POST['name'];
                $email = $_POST['email'];
                $phone = $_POST['phone'];
        }
}

运行网页~~test_v文件向控制器发送信息~~但有错误~~怎么改啊?我刚学CI框架



xcps 发表于 2013-4-7 09:28:12

请问楼主这个问题解决了没,我最近遇到这个问题了!!!
页: [1]
查看完整版本: 请教一个关于ci和ajax得问题~~~