復制代碼 代碼如下:
<script type="text/javascript" src="__PUBLIC__/js/base.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/prototype.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/mootools.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/Ajax/ThinkAjax.js"></script>
<script type="text/javascript">
function checktitle()
{
ThinkAjax.send('__URL__/checktitle','ajax=1&title='+$('title').value,'','checkbox');
}
</script>
<form action="__URL__/insert" method="post">
<table>
<tbody>
<tr>
<td>標題:</td>
<td>
<input type="text">
<input type="button" value="檢查">
</td>
<td>
<span></span>
</td>
</tr>
</tbody>
</table>
</form>
復制代碼 代碼如下:
<?php
class IndexAction extends Action
{
// 首頁
public function index(){
$this->display();
}
// 檢查標題是否可用
public function checkTitle()
{
if(!empty($_POST['title']))
{
$Form = D("Form");
if($Form->getByTitle($_POST['title']))
{
$this->error('標題已經存在');
}
else
{
$this->success('標題可以使用!');
}
}
else
{
$this->error('標題不能為空...');
}
}
}
?>
新聞熱點
疑難解答