New to jQuery and Have a Problem

New to jQuery and Have a Problem

I'm working on reviving a project and currently the project uses jQuery 1.6.2 and works fine with it however as part of the revival, it needs to be upgraded so we can take advantage of newer technologies, etc.

When I replace jQuery 1.6.2 with 1.9.1, the script fails to load any data and returns this error in Firebug

    
Error: Syntax error, unrecognized expression: a[href="#home"],

On the HTML page, I have this code currently:

  1. jQuery(document).ready(function() {
  2. function request(page) {
  3. jQuery('#content').html('<h2 class="mainHeading">Loading</h2><p>Requesting content from server, please wait.</p>');
  4. jQuery.ajax({
  5. url: 'index.php',
  6. type: "GET",
  7. data: "page=" + page,
  8. timeout: 15000
  9. })
  10. .error(function(xhr, status) {
  11. var errorMsg = '<p>Error loading the page!</p>';
  12. if(null != status) {
  13. errorMsg = 'Sorry, but "' + status + '" occured!';
  14. }
  15. jQuery('#content').html('<h2 class="mainHeading">Error</h2>' + errorMsg);
  16. })
  17. .success(function(data) {
  18. jQuery('<?php echo genNav(); ?>').removeClass('active');
  19. jQuery('a[href="#' + data.pageName + '"]').addClass('active');
  20. jQuery('#content').html(data.content);
  21. });
  22. }
  23. jQuery('<?php echo genNav(); ?>').click(function(e) {
  24. e.preventDefault();
  25. var pageName = jQuery(this).attr('href').split("#")[1];
  26. request(pageName);
  27. });
  28. request('home');
  29. });

And the genNav function is here:



  1. function genNav() {
  2. if ($handle = opendir('tpl')) {
  3. while (false !== ($file = readdir($handle))) {
  4. if ($file != "." && $file != "..") {
  5. $file = substr($file, 0, -(strlen($file)-(strrpos($file, "."))));
  6. if ($file == "wsl"){ } else {
  7. echo "a[href=\"#$file\"],";
  8. }
  9. }
  10. }
  11. closedir($handle);
  12. }
  13. }
What's the problem here? Could someone please help me make sense of 
what the issue is and how I could resolve this? Thank you!