博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
dojo ajax 传参_使用Dojo动画AJAX记录删除
阅读量:2521 次
发布时间:2019-05-11

本文共 1631 字,大约阅读时间需要 5 分钟。

dojo ajax 传参

I'm a huge fan of WordPress' method of individual article deletion. You click the delete link, the menu item animates red, and the item disappears. Here's how to achieve that functionality with Dojo JavaScript.

我非常喜欢WordPress删除个别文章的方法。 单击删除链接,菜单项设置为红色,然后消失。 这是使用Dojo JavaScript实现该功能的方法。

PHP-内容和标题 (The PHP - Content & Header)

The following snippet goes at the top of the page:

以下代码段位于页面顶部:

if(isset($_GET['delete'])) {	$query = 'DELETE FROM my_table WHERE item_id = '.(int)$_GET['delete'];	$result = mysql_query($query,$link);}

The following is used to display the records:

以下用于显示记录:

$query = 'SELECT * FROM my_table ORDER BY title ASC';$result = mysql_query($query,$link);while($row = mysql_fetch_assoc($result)) {	echo '
Delete
',$row['title'],'
';}

Dojo工具包JavaScript (The Dojo Toolkit JavaScript)

dojo.addOnLoad(function() {	dojo.query('a.delete').connect('onclick',function(e) {		var a = this;		dojo.anim(a.parentNode,{			backgroundColor: '#fb6c6c'		},300);		dojo.stopEvent(e);		dojo.xhr('get',{			content: {				ajax: 1			},			url: dojo.attr(a,'href'),			load: function() {				dojo.anim(a.parentNode,{					opacity: 0				},300,null,function() {					dojo.query(a.parentNode).orphan();				});			}		});	});});

For every link, we add a click event that triggers the AJAX request. During the request, we transition the containing element to a red background. When the AJAX request returns a "success" response, we slide the element off of the screen.

对于每个链接,我们添加一个点击事件来触发AJAX请求。 在请求期间,我们将包含元素转换为红色背景。 当AJAX请求返回“成功”响应时,我们将元素滑出屏幕。

How would you use this? Share!

您将如何使用它? 分享!

翻译自:

dojo ajax 传参

转载地址:http://dgswd.baihongyu.com/

你可能感兴趣的文章
volatile
查看>>
项目需求分析答辩总结
查看>>
mysql-6正则表达式
查看>>
廖雪峰Java2面向对象编程-5包和classpath-1包package
查看>>
廖雪峰Java7处理日期和时间-3java.time的API-1LocalDateTime
查看>>
利用golang语法检查对象是否实现了接口
查看>>
在UBUNTU上安装基于bochs的 xv6
查看>>
Azure Storage Blob文件重命名
查看>>
RxJava2.0 使用
查看>>
FreeImage的图像处理软件
查看>>
ASP.NET MVC开发必看系列
查看>>
点到平面的距离
查看>>
linux下安装FTP
查看>>
第四周编程总结
查看>>
《第12章 类的无参方法》
查看>>
经典机器学习算法系列7-svd
查看>>
mxnet系列 全连接层代码阅读
查看>>
0715
查看>>
Android开发进度06
查看>>
Beautiful Soup 中文文档
查看>>