javascript - How to store div content to DB with Ajax -
in project, want store div content db. content like:
<span>name:</span><input type="text" id="inputid" value="john"><br />
so chose innerhtml fetch them successfully. , ajax, content stored db.
yesterday, found stripslashes() should called format content, , updated successfully.
but today stripslashes() made nothing done. here js code:
var slcid = $('#slcstnum').val(); var tmtgdvhtml=document.getelementbyid("timetagdiv").innerhtml; $.ajax({ datatype:'html', type:"post", url:"get_ajax_csc_div.php", data:{htmlcnt:tmtgdvhtml,slcid:slcid}, success:function (data) { alert("test"); } });
here html code:
<div id="timetagdiv"><span>name:</span><input type="text" id="inputid" value="john"><br /></div>
here get_ajax_csc_div.php code
<?php if(isset($_post['htmlcnt'])) { include("db.php"); $htcnt=stripslashes(".$_post['htmlcnt']."); $sql="update idc set stprocess='$htcnt' id='".$_post['slcid']."';"; $sel = $conn->exec($sql); } ?>
i changed datatype:'html' datatype:'json', failed again. can me?
it's because have _post[]
superglobal surrounded quotes, making string.
change this
$htcnt = stripslashes(".$_post['htmlcnt'].");
with this
$htcnt = stripslashes($_post['htmlcnt']);
Comments
Post a Comment