Javascript 如何使用Ajax将div内容存储到DB
在我的项目中,我想将div内容存储到DB中。内容如下:Javascript 如何使用Ajax将div内容存储到DB,javascript,php,jquery,Javascript,Php,Jquery,在我的项目中,我想将div内容存储到DB中。内容如下: <span>name:</span><input type="text" id="inputid" value="John"><br /> 以下是html代码: <div id="timeTagDiv"><span>name:</span><input type="text" id="inputid" value="John"><br /
<span>name:</span><input type="text" id="inputid" value="John"><br />
以下是html代码:
<div id="timeTagDiv"><span>name:</span><input type="text" id="inputid" value="John"><br /></div>
名称:
下面是get\u ajax\u csc\u div.php代码
<?php
if(isset($_POST['htmlCnt']))
{
include("DB.php");
$htcnt=stripslashes(".$_POST['htmlCnt'].");
$sql="update IDC SET stprocess='$htcnt' where id='".$_POST['slcId']."';";
$sel = $conn->exec($sql);
}
?>
这是因为你的\u POST[]
超全局被引号包围,使其成为一个字符串
改变这个
$htcnt = stripslashes(".$_POST['htmlCnt'].");
用这个
$htcnt = stripslashes($_POST['htmlCnt']);
将您的get\u ajax\u csc\u div.php更改为
include("DB.php");
if(isset($_POST['htmlCnt'])) {
$htcnt = stripslashes($_POST['htmlCnt']);
$sql = "update IDC SET stprocess='$htcnt' where id='".$_POST['slcId']."'";
$sel = $conn->exec($sql);
}
控制台中有错误吗?有错误吗??在控制台中,最可能是因为$u POSTAlso周围有引号,所以插入查询有问题$sql=“更新IDC集stprocess='$htcnt'其中id='”$\u POST['slcId']。“”代码>
include("DB.php");
if(isset($_POST['htmlCnt'])) {
$htcnt = stripslashes($_POST['htmlCnt']);
$sql = "update IDC SET stprocess='$htcnt' where id='".$_POST['slcId']."'";
$sel = $conn->exec($sql);
}