title: Phantomjs does not execute function in page.evaluate function
body: <p>I'm scraping a Facebook page with the PhantomJS node module (<a href="https://github.com/sgentle/phantomjs-node" rel="noreferrer">https://github.com/sgentle/phantomjs-node</a>), but when I try evaluating the page, it does not evaluate the function I pass to it. Executing it in a standalone script and running it with the Node interpreter works.. The same code in an Express.js app does not work.</p>
  
  <p>This is my code</p>
  
  <pre><code>facebookScraper.prototype.scrapeFeed = function (url, cb) {
      f = ':scrapeFeed:';
  
      var evaluator = function (s) {
          var posts = [];
  
          for (var i = 0; i &lt; FEED_ITEMS; i++) {
              log.info(__filename+f+' iterating step ' + i);
              log.info(__filename+f+util.inspect(document, false, null));
          }
  
          return {
              news: posts
          };
      }
  
      phantom.create(function (ph) {
          ph.createPage(function (page) {
              log.fine(__filename+f+' opening url ' + url);
              page.open(url, function (status) {
                  log.fine(__filename+f+' opened site? ' + status);
                  setTimeout(function() {
                      page.evaluate(evaluator, function (result) {
                          log.info(__filename+f+'Scraped feed: ' + util.inspect(result, false, null));
                          cb(result, ph);
                      });
                  }, 5000);
              });
          });
      });
  };
  </code></pre>
  
  <p>The output I get:</p>
  
  <pre><code>{"level":"fine","message":"PATH/fb_regular.js:scrapeFeed: opening url &lt;URL&gt; ","timestamp":"2012-09-23T18:35:10.151Z"}
  {"level":"fine","message":"PATH/fb_regular.js:scrapeFeed: opened site? success","timestamp":"2012-09-23T18:35:12.682Z"}
  {"level":"info","message":"PATH/fb_regular.js:scrapeFeed: Scraped feed: null","timestamp":"2012-09-23T18:35:12.687Z"}
  </code></pre>
  
  <p>So, as you see, it calls the phantom callback function (second parameter in the evaluate function) with a null argument, but it doesn't execute the first parameter (my evaluator function, which prints iterating step X).</p>
  
  <p>Anyone knows what the problem is?</p>