I’m inserting some data into a div container via ajax. When its just straight html being loaded into the div it works fine, however when I try to insert a javascript function in script tags it causes the page to refresh and hang when the ajax is enabled. How would I insert this script into the div container via 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>
The showtext function is contained in functions.php. This file isn’t included with loadmore.php. Could that be causing the problem? Here it is:
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>");
}
Are you trying to show some sort of pop-up/lightbox type window? If so, I would suggest not doing this, but more something like so:
That said, what was
showtext? Can you show that function?EDIT
I guess what I am saying, is why would you pass a function like this, and not just pass the text to the function… Maybe I am on the wrong path