This question already has answers here:
How can I get useful error messages in PHP?
(42个答案)
4年前关闭。
没有显示错误消息。只是空白的白色屏幕。
Firefox的控制台说:未声明HTML文档的字符编码。如果文档包含来自US-ASCII范围之外的字符,则在某些浏览器配置中,文档将呈现乱码。页面的字符编码必须在文档或传输协议中声明。
在我的functions.php文件中,添加了以下代码:
我的实际JavaScript文件:
在我将新的wp_enqueue_script函数添加到我的functions.php文件之后,出现空白的白色屏幕。如果我删除了代码,该站点将正常运行。
请考虑将IDE与语法错误突出显示一起使用,以免造成此类偶然错误
(42个答案)
4年前关闭。
没有显示错误消息。只是空白的白色屏幕。
Firefox的控制台说:未声明HTML文档的字符编码。如果文档包含来自US-ASCII范围之外的字符,则在某些浏览器配置中,文档将呈现乱码。页面的字符编码必须在文档或传输协议中声明。
在我的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文件之后,出现空白的白色屏幕。如果我删除了代码,该站点将正常运行。
最佳答案
您有语法错误-其他);
。请删除它,以便您的功能变为:
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' );
}
请考虑将IDE与语法错误突出显示一起使用,以免造成此类偶然错误