Document.write()在wordpress标题中不起作用[关闭]

Document.write()在wordpress标题中不起作用[关闭]

问题描述:

I've got some javascript which uses AJAX to get the output of a php file.

I've been using document.write(data) to show the content which works fine when it's just the script, but when I incorporate the script into wordpress through the header.php, the script works ok except for document.write().

Instead of showing the content received from the AJAX it just reloads the wordpress page.

How can I get around this? I don't mind loading the result in a fresh tab if I an do that and if it helps.

我有一些javascript使用AJAX来获取php文件的输出。 p>

我一直在使用document.write(data)来显示只是脚本时工作正常的内容,但是当我通过header.php将脚本合并到wordpress中时, 脚本工作正常除了document.write()。 p>

不是显示从AJAX收到的内容,而是重新加载wordpress页面。 p>

我如何解决这个问题? 如果我这样做并且有帮助,我不介意将结果加载到新标签中。 p> div>

Rather than using document.write, what you really want to do is append your content to a specific element within the body. You can do this very easily through jQuery:

jQuery('#containerId').append('Content I'd like to add to the page.');