繁体   English   中英

使用jquery,ajax和php将div中的更新数据保存到数据库

[英]Save updated data in a div to a database using jquery, ajax and php

我有一个包含电子表格的表行和列的div(我使用的是http://jquerysheet.googlecode.com/svn/branches/3.x/jquery.sheet.html ),单击按钮后,我使用ajax来获取div中的内容通过id进入数据库。 问题是当我更新电子表格并保存时,它不会将更新的内容发送到数据库。 而是发送默认内容。

纽扣

<a href='#' id="fat-btn" class="btn btn-info" data-loading-text="Saving, Please Wait ..."> Save Sheet </a>

jQuery /阿贾克斯

$('#fat-btn').click(function() {

            var content = $('#sheetParent').html();

            $.ajax({
                url: 'sendtodatabase.php',
                type: 'POST',
                data: {
                    content: content
                }
            });
        });




    });

sendtodatabase.php

<?php

require_once("conn.php");

$resval=$_REQUEST['content'];

$ins=mysql_query("update tabula set sheet='$resval' where id='5'")or die(mysql_error());

?>

DIV

<div id="sheetParent">    

<table width="100%" border="0" cellspacing="0" cellpadding="0">
 <tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>

</table>

谁能帮助我如何将更新的div内容导入数据库? 注意:我是新手。

您尝试放入数据库中的div不包含要保存的数据,而是以新元素呈现的(我建议您查看工作表的实际来源,您会发现有很多事情发生了(jSUI等)。您是否尝试过此活动?

sheetSave: function(e, jS, tables) 

“表”是参数之一,应为您提供所需的数据。 hth

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM