Uncaught ReferenceError: Nitrogen is not defined

250 Views Asked by At

I am running a Nitrogen web framework over Yaws driven site. It has been working properly on all browsers for the last three years. But recently postbacks could unpredictably fail to respond in Google Chrome and Opera. with the error in the console of Uncaught ReferenceError: Nitrogen is not defined. The referenced error line shows this

Nitrogen.$set_param('pageContext', 'j-oHyfcHcpNAZCWh7t6Y5EBqMbhta0E01Fl0jNMCOlr0YfeAEUGiprZ21Oqs1rDf6nutqrfw5LPfy9W1x8kk_k4-Z_adkaQy9Ijk66RY7hoi0kIbsf6RV34ZCJp8YXOu9SGNGe8tHLS-JbeiVzhzBIqfSUC5KXu1eLjVhzip_Z_dAxRWu3yzgG8pgCLvWqSIG8LbeG-C4kPZIrYQL9Y27cDdQHTLN1nbStbMekOw6Iviu-F19Jp5RW2ojIrkH2AscKqwIg');

I have tried to find out the cause of the error but in vain and what confuses me more is that it has just started and not on every browser and not on every computing terminal.

This is how my template looks like

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
   <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
   <title>[[[page:title()]]]</title>
   <script src='/nitrogen/jquery.js' type='text/javascript' charset='utf-8'></script>
   <script src='/nitrogen/jquery-ui.js' type='text/javascript' charset='utf-8'></script>
   <script src='/nitrogen/livevalidation.js' type='text/javascript' charset='utf-8'></script>
   <script src='/nitrogen/nitrogen.js' type='text/javascript' charset='utf-8'></script>
   <script src='/nitrogen/bert.js' type='text/javascript' charset='utf-8'></script>
   <link rel="stylesheet" href="/nitrogen/jquery-ui/jquery.ui.all.css" type="text/css" media="screen" charset="utf-8" />
   <link rel="stylesheet" href="/nitrogen/nitrogen.css" />  

   <!-- For google analytics -->
   <script>
    ...some google code here ....
   </script>     
</head>

<body ">
  [[[page:body()]]]
  <script>
    [[[script]]]
  </script>
</body>
</html>

Any help please.

2

There are 2 best solutions below

6
chops On

First, I doubt it's related, but do you really have a stray unclosed double-quote (") in your tag, or that just a stray Copy-and-paste remnant. It's the first thing that stood out to me.

Secondly, the cause of this error is a bit elusive, but here are some threads you can pull on to try to unravel this mystery:

  • The error "Nitrogen is not defined" can be caused only by one of a few things:
    1. The nitrogen.js script is not loaded at all (serving static content failed). This you can check the Network tab in CTRL+SHIFT+I to see what the response of nitrogen.js is
    2. The nitrogen.js script crashed, which would show in the js console, but you haven't mentioned it, so it's probably not this.
    3. Something happened that called Nitrogen=undefined

With that said:

  • Are you able to reproduce this error yourself, or are you going on user reports?
  • When the postbacks fail, are they failing after the page has loaded and other things have happened, or are they failing right away on page load?

This is definitely a new error for me - not a problem I've encountered except when something is causing static content to fail to load in the first place.

0
jianwei On

I have the same problem when use the nitrogen , and I copy these files(jquery.js、jquery-ui.js...the files mentioned in the template html) to the directory "./site/static/nitrogen" ,and the problem had fixed. These js files can be found in "./lib/nitrogen_core/www", If you can not find them in your installation package, you can download the binares version of nitrogen.