ฉันกำลังแทรกข้อมูลบางอย่างลงในคอนเทนเนอร์ div ผ่าน ajax เมื่อโหลด HTML โดยตรงลงใน div มันก็ทำงานได้ดี แต่เมื่อฉันพยายามแทรกฟังก์ชันจาวาสคริปต์ในแท็กสคริปต์ มันจะทำให้เพจรีเฟรชและหยุดทำงานเมื่อเปิดใช้งาน ajax ฉันจะแทรกสคริปต์นี้ลงในคอนเทนเนอร์ div ผ่าน ajax ได้อย่างไร
<script type='text/javascript'>
showtext('By clicking this link you have activated the coupon. View the newly opened Kensie window to view this deal!','coupon-23147');
</script>
ฟังก์ชัน showtext มีอยู่ใน Functions.php ไฟล์นี้ไม่รวมอยู่ใน loadmore.php นั่นอาจทำให้เกิดปัญหาหรือไม่? นี่คือ:
function showtext(text,id) {
document.write("<div style='display:none'><div id='" + id + "'><table align='center' bgcolor='ffffff' border='0' width='450' height='180'><tr><td><font face='Arial, Helvetica, sans-serif' size='4'><center>" + text + "<br/><br/><IMG border='0' src='http://static.mydomain.com/images/logonew1.png' align='center'></center></td></tr></table></div></div>");
}