复制代码 代码如下:
<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('标题不能为空...');
}
}
}
?>
新闻热点
疑难解答