php通过ajax实现双击table修改内容

yipeiwu_com5年前PHP代码库
复制代码 代码如下:

<script type="text/javascript">
$(function() {

$("td").dblclick(function() { //获取标签
var td = $(this);
var itemid=td[0].id;
var txt = td.text();
var input = $("<input type='text' value='" + txt + "'/>");
td.html(input);
input.click(function() { return false; });
//获取焦点
input.trigger("focus");

input.blur(function() {
var newtxt = $(this).val();

if (newtxt != txt) {
td.html(newtxt);
var caid = $.trim(td.prev().text());

/*这里做ajax去后台操作

var url = "?a.php&itemid=" + itemid + "&v=" + newtxt; //具体根据网站情况而定

$.get(url, function(data) {
if(data=="1")
{
location.reload();
td.html(txt);
return;
}
td.html(newtxt);
});

}
else
{
td.html(newtxt);
}
});

*/

});
});
</script>

相关文章

几个实用的PHP内置函数使用指南

几个实用的PHP内置函数使用指南

PHP有许多内置函数,其中大多数函数都被程序员广泛使用。但也有一些函数隐藏在角落,本文将向大家介绍7个鲜为人知,但用处非常大的函数。 没用过的程序员不妨过来看看。   1.highli...

PHP学习笔记 IIS7下安装配置php环境

PHP学习笔记 IIS7下安装配置php环境

Php如何安装 Php版本的选择 Php在windows下的(php5.4.7)有两种版本: VC9 x86 Non Thread Safe 非线程安全型 以FastCGI模式运行 VC...

深入PHP数据加密详解

数据加密在我们生活中的地位已经越来越重要了,尤其是考虑到在网络上发生的大量 交易和传输的大量数据。如果对于采用安全措施有兴趣的话,也一定会有兴趣了解PHP提供的一系列安全功能。在本篇文章...

php自动获取字符串编码函数mb_detect_encoding

当在php中使用mb_detect_encoding函数进行编码识别时,很多人都碰到过识别编码有误的问题,例如对与GB2312和UTF- 8,或者UTF-8和GBK(这里主要是对于cp9...

支持生僻字且自动识别utf-8编码的php汉字转拼音类

拼音类文件py_class.php源码如下: <?php class py_class{ function py_class(){ $this ->...