簡體   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