 |
|
ช่วยหาคำตอบให้หน่อยครับ
คือว่า ผมจะดึงค่าใน ckeditor ที่เป็น iframe แต่ยังติดปัญหาการดึงค่าออกมาเป็น null
โดยลอง alert ทดสอบดู
ระบบการทำงานคือ
บึนทึกค่านี้ลง database ทุกๆ 10 วินาที แบบ ajax
โดยทำตาม http://www.jquery.in.th/how-to-access-iframe-by-jquery/ ทุกประการ
อันนี้โค๊ด php ที่จะดึงค่า iframe
Code (PHP)
<td id="cke_contents_x_detail" class="cke_contents" role="presentation" style="height:240px">
<iframe frameborder="0" allowtransparency="true" tabindex="0" src="" title="Rich text editor, x_detail, press ALT 0 for help." style="width:100%;height:100%">
<html lang="th" dir="ltr">
<head>
<body class="cke_show_borders" contenteditable="true" spellcheck="false">
<p>ทดสอบส่งค่านี้เก็บ ลง database ทุกๆ 10 วินาที แบบ ajax</p>
</body>
</html>
</iframe>
</td>
Code (PHP)
<script type="text/javascript">
$(function(){
var runajax = setInterval("updatecash()",10000);
});
function updatecash()
{
var p_detail = $("eq:[0]").contents().find(".cke_show_borders").html();
//alert(p_detail);
$.post("topic_cash.php",{
action:"update",
detail: p_detail ,
last_id:'.$lastid.'
} ,
function(data) {
//alert("Received Data: " + data);
});
}
</script>
และ ajax ยิงมาไฟล์นี้
Code (PHP)
$coninw = mysql_connect("localhost","root","");
if (!$coninw)
{
die('ติดต่อฐานข้อมูลไม่ได้ เนื่องจาก: ' . mysql_error());
}
mysql_select_db("myflorisbc_db", $coninw);
if($_POST[action]=='update'){
mysql_query("UPDATE cash SET category_id='$_POST[cat_id]',title='$_POST[title]',detail='$_POST[detail]',modified_date='$datenow' WHERE id='$_POST[last_id]'");
}
mysql_close()
ผู้รู้ช่วยทีนะครับ เป็นพระคุณอย่างสูง
Tag : PHP, MySQL, HTML/CSS, JavaScript, Ajax, jQuery
|
|
 |
 |
 |
 |
Date :
2012-03-09 16:32:10 |
By :
akimura69 |
View :
2164 |
Reply :
2 |
|
 |
 |
 |
 |
|
|
|
 |