title: Reference Error: response is not defined AngularJs
body: <p>I'm following this <a href="https://www.webslesson.info/2016/09/angularjs-tutorial-with-php-fetch-select-data-from-mysql-database.html" rel="nofollow noreferrer">tutorial</a> to retrieve data from a database. The retrived data from the server is a json array and it contains these two objects: </p>
  
  <pre><code>[{"_id":{"$oid":"5ae81566f3a9bd1fe8002d34"},"Customer_Name":"cXQzbXlUeHRVckFvVGpoVUQxaHNoQT09","Responsiple_User":"Wjc0TFpMbUtyUlo1bGptZ1RCOG84Zz09","Phone_Number":"Wjc0TFpMbUtyUlo1bGptZ1RCOG84Zz09","ID_Number":"Wjc0TFpMbUtyUlo1bGptZ1RCOG84Zz09","Sale":"Wjc0TFpMbUtyUlo1bGptZ1RCOG84Zz09","Resposible_Sales":"Wjc0TFpMbUtyUlo1bGptZ1RCOG84Zz09","City":"Wjc0TFpMbUtyUlo1bGptZ1RCOG84Zz09","Job":"Wjc0TFpMbUtyUlo1bGptZ1RCOG84Zz09","Monhthly_Income":"Wjc0TFpMbUtyUlo1bGptZ1RCOG84Zz09","Number_Of_Months":"SVFxZVJkWG0vaUhxSUxFNzdrWjZCZz09","Monthly_installment_of_the_client":"Wjc0TFpMbUtyUlo1bGptZ1RCOG84Zz09","First_Payment":"Wjc0TFpMbUtyUlo1bGptZ1RCOG84Zz09","Bank":"Wjc0TFpMbUtyUlo1bGptZ1RCOG84Zz09","Financial_Situation":"Wjc0TFpMbUtyUlo1bGptZ1RCOG84Zz09","Account":"Wjc0TFpMbUtyUlo1bGptZ1RCOG84Zz09","Notes":"Wjc0TFpMbUtyUlo1bGptZ1RCOG84Zz09","Date":"2018-05-01 09:21:10"},{"_id":{"$oid":"5ae8157ff3a9bd1fe8002d36"},"Customer_Name":"aGxveGF1SGxKWXpFajgzSGI0RmE0QT09","Responsiple_User":"Wjc0TFpMbUtyUlo1bGptZ1RCOG84Zz09","Phone_Number":"Wjc0TFpMbUtyUlo1bGptZ1RCOG84Zz09","ID_Number":"Wjc0TFpMbUtyUlo1bGptZ1RCOG84Zz09","Sale":"Wjc0TFpMbUtyUlo1bGptZ1RCOG84Zz09","Resposible_Sales":"Wjc0TFpMbUtyUlo1bGptZ1RCOG84Zz09","City":"Wjc0TFpMbUtyUlo1bGptZ1RCOG84Zz09","Job":"Wjc0TFpMbUtyUlo1bGptZ1RCOG84Zz09","Monhthly_Income":"Wjc0TFpMbUtyUlo1bGptZ1RCOG84Zz09","Number_Of_Months":"Wjc0TFpMbUtyUlo1bGptZ1RCOG84Zz09","Monthly_installment_of_the_client":"Wjc0TFpMbUtyUlo1bGptZ1RCOG84Zz09","First_Payment":"Wjc0TFpMbUtyUlo1bGptZ1RCOG84Zz09","Bank":"Wjc0TFpMbUtyUlo1bGptZ1RCOG84Zz09","Financial_Situation":"Wjc0TFpMbUtyUlo1bGptZ1RCOG84Zz09","Account":"SVFxZVJkWG0vaUhxSUxFNzdrWjZCZz09","Notes":"Wjc0TFpMbUtyUlo1bGptZ1RCOG84Zz09","Date":"2018-05-01 09:21:35"}]
  </code></pre>
  
  <p>I modified the code in the tutorial to display only the json data in the table. The problem is that I keep getting the issue of response is not defined. Below is my code </p>
  
  <pre><code>&lt;!DOCTYPE html&gt;  
   &lt;!-- index.php !--&gt;  
   &lt;html&gt;  
        &lt;head&gt;  
             &lt;title&gt;test&lt;/title&gt;  
             &lt;link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" /&gt;  
             &lt;script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"&gt;&lt;/script&gt;  
        &lt;/head&gt;  
        &lt;body&gt;  
             &lt;br /&gt;&lt;br /&gt;  
             &lt;div class="container" style="width:500px;"&gt;  
                  &lt;h3 align="center"&gt;AngularJS Tutorial with PHP - Fetch / Select Data from Mysql Database&lt;/h3&gt;  
                  &lt;div ng-app="myapp" ng-controller="usercontroller" ng-init="displayData()"&gt;  
  
                       &lt;table class="table table-bordered"&gt;  
                            &lt;tr&gt;  
                                 &lt;th&gt;First Name&lt;/th&gt;  
                                 &lt;th&gt;Last Name&lt;/th&gt;  
                            &lt;/tr&gt;  
                            &lt;tr ng-repeat="x in names"&gt;  
                                 &lt;td&gt;{{x.City}}&lt;/td&gt;  
                                 &lt;td&gt;{{x.last_name}}&lt;/td&gt;  
                            &lt;/tr&gt;  
                       &lt;/table&gt;  
                  &lt;/div&gt;  
             &lt;/div&gt;  
        &lt;/body&gt;  
   &lt;/html&gt;  
   &lt;script&gt;  
   var app = angular.module("myapp",[]);  
   app.controller("usercontroller", function($scope, $http){  
  
        $scope.displayData = function(){  
        alert ("s");
             $http.get("data.php",$scope.names = response ).success(function(response){});  
  
        }  
   });  
   &lt;/script&gt;  
  </code></pre>