gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-28 09:20:55 25 4
gpt4 key购买 nike

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

按钮

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

Jquery/Ajax

$('#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 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) 

'tables' 作为参数之一,应该可以为您提供所需的数据。第h

关于php - 使用 jquery、ajax 和 php 将 div 中更新的数据保存到数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14977567/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com