<分区>
没有显示错误信息。只是空白的白色屏幕。
Firefox 的控制台显示:未声明 HTML 文档的字符编码。如果文档包含 US-ASCII 范围之外的字符,则在某些浏览器配置中,文档将呈现为乱码文本。页面的字符编码必须在文档或传输协议(protocol)中声明。
在我的 functions.php 文件中,我添加了这段代码:
function comparison_js() {
wp_register_script( 'custom-script', get_template_directory_uri() . '/js/comparison-js.js', array( 'jquery' ),'1.0.0',true );
wp_enqueue_script( 'custom-script' );
);
}
add_action( 'wp_enqueue_scripts', 'comparison-js' );
我实际的 javascript 文件:
jQuery(document).ready(function($) {
jQuery('a').on('click', function(e){
//Prevent the link from working as an anchor tag
e.preventDefault();
//Declare 'this' outside of AJAX because of asynchronous nature of call
that = jQuery(this);
//Make AJAX call to the PHP file/database query
jQuery.ajax({
url:'http://dirtypoliticsph.com/wp-content/themes/twentythirteen/templatecode.php',
type:'POST',
data:{id:jQuery(this).data('id')},
success:function(data){
that.append(data);
}
});
});
});
在我将新的 wp_enqueue_script 函数添加到我的 functions.php 文件后出现空白屏幕。如果我删除代码,网站就会正常运行。