1

No error messages shown. Just blank white screen.

Firefox's console says: The character encoding of the HTML document was not declared. The document will render with garbled text in some browser configurations if the document contains characters from outside the US-ASCII range. The character encoding of the page must be declared in the document or in the transfer protocol.

In my functions.php file, I added this code:

    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' );

My actual javascript file:

    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);
        }
            });
        });
    });

The blank white screen appears AFTER I added the new wp_enqueue_script function to my functions.php file. If I remove the code, the site comes up normal.

thomas
  • 163
  • 2
  • 13
  • My template file that is being affected has the following code: `ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL);` – thomas Dec 16 '15 at 15:29

1 Answers1

2

You have syntax error - additional );. Please remove it so your function becomes :

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' );
}

Please consider using IDE with syntax error highlight so you can avoid such casual errors

pavlovich
  • 1,935
  • 15
  • 20
  • damn....silly mistake. thanks. can't believe I overlooked that. But now the console is telling me: Empty string passed to getElementById(). – thomas Dec 16 '15 at 15:33
  • @thomas Glad it worked out. Also one more tip: during development when you are getting blank screens (which do not tell you the error), you can read real error messages in Apache log (in case you are using Apache and linux they are usually located in `/var/log/apache2`). Just see which logs are latest by modification time with `ls -ltr` – pavlovich Dec 16 '15 at 15:38