Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/423.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何使用Ajax将div内容存储到DB_Javascript_Php_Jquery - Fatal编程技术网

Javascript 如何使用Ajax将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 /

在我的项目中,我想将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 /></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);  
}