title: cannot pass data from php script to angularjs using angularjs php
body: <p>when ever i tried to update form response from php script shows undefined.<br />
  <strong>script.js</strong></p>
  <pre><code>$scope.Edit = function() {
    $http.post(&quot;update.php&quot;, {
      'id' : $scope.id,
         'Name': $scope.Name
      })
      .then(function(response){
          $scope.names = response.data;
          console.log(response.data.success);
       }, function(){
          console.log(response.data.fail);
       })
   }
  </code></pre>
  <p><strong>update.php</strong></p>
  <pre><code>&lt;?php
      try {
          header('Access-Control-Allow-Origin: *');
          header('Content-Type: application/json; charset=utf-8');
          $link = new PDO(&quot;mysql:host=localhost;dbname=angularjs&quot;, &quot;root&quot;, &quot;&quot;);
          $link-&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
          $response = array();
          $json = json_decode(file_get_contents(&quot;php://input&quot;), true);
          $Sql = &quot;UPDATE register SET Name = :Name WHERE id = :id&quot;;
          $stmt = $link-&gt;prepare($Sql);
          $stmt-&gt;bindParam(&quot;:Name&quot;, $json['Name'], PDO::PARAM_STR);
          $stmt-&gt;bindParam(&quot;:id&quot;, $json['id'], PDO::PARAM_STR);
          $stmt-&gt;execute();
          $response['success'] = &quot;successfully inserted&quot;; 
      } catch (Exception $e) {
          $response['fail'] = &quot;Error.&quot;.$e;
      }
  ?&gt;
  </code></pre>
  <p><strong>template.html</strong></p>
  <pre><code>&lt;div class=&quot;container&quot; ng-controller=&quot;welcomeController&quot;&gt;
      &lt;h1&gt;{{ name }}&lt;/h1&gt;
      &lt;p&gt;{{ success }}&lt;/p&gt;
      &lt;p&gt;{{ fail }}&lt;/p&gt;
      &lt;div class=&quot;table-responsive&quot;&gt;
          &lt;table class=&quot;table table-hover table-borderless&quot;&gt;
              &lt;thead&gt;
                  &lt;tr&gt;
                      &lt;th&gt;Id&lt;/th&gt;
                      &lt;th&gt;Name&lt;/th&gt;
                      &lt;th&gt;Email&lt;/th&gt;
                      &lt;th&gt;DOB&lt;/th&gt;
                      &lt;th&gt;Edit&lt;/th&gt;
                      &lt;th&gt;Delete&lt;/th&gt;
                  &lt;/tr&gt;
              &lt;/thead&gt;
              &lt;tbody ng-repeat=&quot;users in names&quot;&gt;
                  &lt;tr&gt;
                      &lt;form&gt;
                          &lt;td&gt;&lt;input type=&quot;text&quot; ng-model=&quot;users.id&quot; readonly&gt;&lt;/td&gt;
                          &lt;td&gt;&lt;input type=&quot;text&quot; ng-model=&quot;users.Name&quot;&gt;&lt;/td&gt;
                          &lt;td&gt;{{ users.Email }}&lt;/td&gt;
                          &lt;td&gt;{{ users.DOB }}&lt;/td&gt;
                          &lt;td&gt;&lt;button type=&quot;submit&quot; ng-click=&quot;Edit()&quot; class=&quot;btn btn-success&quot;&gt;Edit&lt;/button&gt;&lt;/td&gt;
                          &lt;td&gt;&lt;button type=&quot;submit&quot; ng-click=&quot;Delete()&quot; class=&quot;btn btn-danger&quot;&gt;Delete&lt;/button&gt;&lt;/td&gt;
                      &lt;/form&gt;
                  &lt;/tr&gt;
              &lt;/tbody&gt;
          &lt;/table&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  <p>i need response from php script as updated successfully but it shows undefined. i tried to debug many times i cannot see what mistake i have done.</p>