求CI用ajax的例子
好像都没怎么找到类似的东西,有人能提供点例子给学习下吗? 首先我先聲明,自己對 ajax 也不是很懂最近的一個案子,剛好會應用到這塊,所以也還在學
但是 google 一下應該有不少資料可以看吧...關鍵字" ajax codeigniter "
我覺得這個例子就不錯:
http://runnable.com/UXczcazDrMMi ... codeigniter-for-php
/controllers/welcome1.php
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Welcome1 extends CI_Controller {
public function index(){
$this->load->view('form-view');
}
}
/controllers/time.php
<?php
class Time extends CI_Controller {
public function index(){
echo time();
}
}
/views/form-view.php
<html>
<head>
<title> Ajax Exmaples! </title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
<script>
$( document ).ready(function () {
$("#button").click(function () {
$.get("time", function (time) {
$("#text").html("Time on the server is:" + time);
});
});
});
</script>
</head>
<body>
<h1> Get Data from Server over Ajax </h1>
<textarea id="text" readonly></textarea>
<br/>
<button id="button">Get Time from Server</button>
</body>
</html>
Closer 发表于 2014-9-24 09:29
首先我先聲明,自己對 ajax 也不是很懂
最近的一個案子,剛好會應用到這塊,所以也還在學
但是 google 一下 ...
您好,请问视图form-view.php里,哪段代码调用了time控制器?{:soso_e100:}
$.get("time", function (time) { Closer 发表于 2014-10-29 09:12
$.get("time", function (time) {
哦,惭愧,得回去补补ajax知识了,十分感谢{:soso_e100:}
页:
[1]