title: Unable to Use String Result From AJAX Request
body: <p>The issue I am having is that I cannot seem to USE the result passed back to the original <code>JS</code> file from the <code>PHP</code> file called from the request. This is the result and handler:</p>
  
  <pre><code>if(creds_verification() == true){
          $.ajax({
          url:"scripts/scripts.php", //the page containing php script
          type: "post", //request type,
          dataType: 'json',
          data: {url: URL, user: USER, password: PASS},
          success:function(result){
              var verdict = result
              if(verdict == "Yes"){
                 Call another external function 
              }else{
              console.log(results.abc)
           }
         }
       });
      }
  </code></pre>
  
  <p>The console is constantly printing "Yes", aka the result of <code>results.abc</code>... why would this happen? It SHOULD be executing the next function...</p>
  
  <p><strong>Added Info</strong>
  <code>PHP</code> script running shell command and <code>echo</code>ing the result:</p>
  
  <p><strong>scripts.php</strong></p>
  
  <pre><code>    &lt;?php  
  $URL = $_POST['url'];
  $USER = $_POST['user'];
  $PASSWORD = $_POST['password'];
  
  echo json_encode(array("abc" =&gt; shell_exec("PATH.../phantomjs PATH/phantom/examples/test.js 2&gt;&amp;1 $URL $USER $PASSWORD")));
  ?&gt;
  </code></pre>
  
  <p>And the <code>JS</code> file this is calling from the shell command:</p>
  
  <p><strong>test.js</strong></p>
  
  <pre><code>var system = require('system')
  var page = require('webpage').create()
  var script = document.createElement('script');
  script.src = 'http://code.jquery.com/jquery-1.11.0.min.js';
  script.type = 'text/javascript';
  document.getElementsByTagName('head')[0].appendChild(script);
  var URL = system.args[1]
  var USER = system.args[2]
  var PASS = system.args[3]
  var steps = [
    function() {
      page.open('http://'+URL+'/login.html')
    },
    function() {
      page.evaluate(function(USER, PASS) {
        document.querySelector('input[name="log"]').value = USER
      document.querySelector('input[name="pwd"]').value = PASS
      document.querySelector('form').submit()
      }, USER, PASS)
    },
  function(){
       var newURL = page.url
       if(newURL == 'http://'+URL+'/user.html'){
        console.log('Yes')
       }else{
        console.log('No?')
       }
  }
  ]
  var stepindex = 0
  var loading = false
  
  setInterval(executeRequestsStepByStep, 5000)
  
  function executeRequestsStepByStep(){
    if (loading == false &amp;&amp; steps[stepindex]) {
      steps[stepindex]()
      stepindex++
    }
    if (!steps[stepindex]) {
      phantom.exit()
    }
  }
  page.onLoadStarted = function() { loading = true }
  page.onLoadFinished = function() { loading = false }
  </code></pre>