title: How to use Phantomjs evaluate to return anything from document?
body: <p>I am using this <a href="https://www.npmjs.com/package/phantom" rel="nofollow">package</a> of phantomjs, because I want to use phantom with node.</p>
  
  <p>My goal here is to get element from given position on given webpage. Everything I try to do I always get <em>null</em>, <em>empty string</em> or <em>Promise {  }</em></p>
  
  <p>Basicly here is my code:</p>
  
  <pre><code>var phantom = require('phantom');
  var sitepage;
  var url = "http://amazon.com";
  
  phantom.create().then(function(ph){
      return ph.createPage();
  }).then(function(page){
      var pageWidth = parseInt("1920px", 10);
      var pageHeight = parseInt(pageWidth * 3/4, 10);
      sitepage = page;
      sitepage.property('settings', {loadImages: false});
      sitepage.property('viewportSize', { width: pageWidth, height: pageHeight });
      return sitepage.open(req.query.url);
  }).then(function(status){
      if (status == "success") {
          var x = 888;
          var y = 777;
  
          var element = sitepage.evaluate(function(x, y) {
              return document.elementFromPoint(x, y).outerHTML;
          }, x, y);
  
          return element;
      }
  
      return '404';
  }).then(function(content){
      console.log(content);
  
      page.close();
      ph.exit();      
  });
  </code></pre>
  
  <p>Inside the last <em>.then()</em> I want to be able to print or save to a variable anything what evaluate returns.</p>
  
  <p>I have tried this many ways and spent multiple hours with no success so far.</p>
  
  <p>EDIT:
  Package I'm using has following example in readme:</p>
  
  <pre><code>page.evaluate(function() {
      return document.getElementById('foo').innerHTML;
  }).then(function(html){
      console.log(html);
  });
  </code></pre>
  
  <p>Not sure if I used it right, but anything I tried hasnt worked yet :\</p>