虚拟主机域名注册-常见问题网络编程问题 → CSS/HTML


div可编辑 enter或离开焦点后提交数据
作者:
<div id="list{$rs['aid']}" contenteditable="true" onblur="postlist('$rs[aid]')" onkeydown="if(window.event.keyCode == 13){event.cancelBubble=true;event.preventDefault();event.stopPropagation();postlist('$rs[aid]')}">{$rs['list']}</div>
function postlist(aid) {
		var xhr = new XMLHttpRequest();
		xhr.open('POST', '?qzurl=$qzurl&dirname=$dirname&file=$file&action=edit_list' );
		xhr.setRequestHeader("Content-type","application/x-www-form-urlencoded");
		xhr.send('aid='+aid+'&list='+document.getElementById("list"+aid).innerText);
		xhr.onreadystatechange = function () {
			if (xhr.readyState == 4 && xhr.status == 200) {
				if(xhr.responseText=='ok'){
					location.reload();
				}
			}
		};
	}


来源:
阅读:1011
日期:2021-05-29

推荐朋友 】 【 评论 】  【 字体: 】 
上一篇:js原生ajax post和get数据
下一篇:js url 编码
  >> 相关文章
  没有相关文章。
发表评论


点  评: 字数0
用户名:  密码:

  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款