jquery添加和删除数据 无刷新,拖动改变排序,jquery无刷新编辑内容并提交
添加和删除数据 ,拖动改变排序,以上都是刷新可以操作的
内容太多了,续点击这里
index.php
PHP Code
- <?php
- require "conn.php";
- require "class.php";
- // Select all the todos, ordered by position:
- $query = mysql_query("SELECT * FROM `add_delete_record` ORDER BY `position` ASC");
- $todos = array();
- // Filling the $todos array with new ToDo objects:
- while($row = mysql_fetch_assoc($query)){
- $todos[] = new ToDo($row);
- }
- ?>
- <div id="main">
- <ul class="todoList">
- <?php
- foreach($todos as $item){
- echo $item;
- }
- ?>
- </ul>
- <a id="addButton" class="green-button" href="#">添加记录</a>
- </div>
- <!-- This div is used as the base for the confirmation jQuery UI POPUP. Hidden by CSS. -->
- <div id="dialog-confirm" title="确定要删除记录?">确定要删除记录</div>
ajax.php
PHP Code
- <?php
- require "conn.php";
- require "class.php";
- $id = (int)$_GET['id'];
- try{
- switch($_GET['action'])
- {
- case 'delete':
- ToDo::delete($id);
- break;
- case 'rearrange':
- ToDo::rearrange($_GET['positions']);
- break;
- case 'edit':
- ToDo::edit($id,$_GET['text']);
- break;
- case 'new':
- ToDo::createNew($_GET['text']);
- break;
- }
- }
- catch(Exception $e){
- // echo $e->getMessage();
- die("0");
- }
- echo "1";
- ?>
原文地址:http://www.freejs.net/article_biaodan_38.html