单击使用Ajax编辑特定的div - php

当单击div时,它应该显示在文本框中,并且应该在“编辑”按钮上可编辑
什么是ajax代码
我已经用php完成了此操作,但想用ajax完成此操作

<script>
function edit()
{

            $.ajax({

            });
}
</script>
<div id="edit1" name="edit1">edit1</div>
<div id="edit2" name="edit2">edit2</div>
<div id="edit3" name="edit3">edit3</div>
<input type="text" id="text"/>
<button onclick="edit(this.value)">Edit</button>

参考方案

demo

    <div>when clicked on the div it should be displayed on textbox 
and it should be editable on edit button what should be the ajax code 
i have done this with php but want to do this with ajax</div>

JS:

function divClicked() {
    var divHtml = $(this).html();
    var editableText = $("<textarea />");
    editableText.val(divHtml);
    $(this).replaceWith(editableText);
    editableText.focus();
    // setup the blur event for this new textarea
    editableText.blur(editableTextBlurred);
}

function editableTextBlurred() {
    var html = $(this).val();
    var viewableText = $("<div>");
    viewableText.html(html);
    $(this).replaceWith(viewableText);
    // setup the click event for this new div
    viewableText.click(divClicked);
}

$(document).ready(function() {
    $("div").click(divClicked);
});

PHP-复选框组 - php

我有一个需要发布的表单复选框组。<input type="checkbox" value="true" checked name="chk0[]"> <input type="checkbox" value="false" name=…

php Singleton类实例将在多个会话中保留吗? - php

举一个简单的例子,如果我想计算一个不使用磁盘存储的脚本的命中次数,我可以使用静态类成员来执行此操作吗?用户1:<?php $test = Example::singleton(); $test->visits++; ?> 用户2:<?php $test = Example::singleton(); $test->visits+…

Div单击与单选按钮相同吗? - php

有没有一种方法可以使div上的click事件与表单环境中的单选按钮相同?我只希望下面的div提交值,单选按钮很丑代码输出如下:<input id="radio-2011-06-08" value="2011-06-08" type="radio" name="radio_date&#…

使用查询获取ID - php

我正在创建一个电子商务网站,我试图添加选项,即买家通过下拉列表选择商品大小,然后将变量传递给jquery,然后将jquery传递给php,如果商品大小可用有库存时,将显示一个添加到购物车按钮,否则显示无库存按钮。我设法使其工作到将项目大小传递给php为止,但是我不知道如何传递产品ID,这是检查数据库所必需的。大小选择:<form id="fo…

使用Ajax呈现html表 - php

我想知道如何实现以下项目其实我有一个php代码,可以渲染一张桌子<table id = "oldata" class ="table table-bordered"> <thead> <tr class ="success"> <th class="…