javascript - Json fetched object showing undefined -


i trying fetch object json , showing undefined. can please. below code.instead of getting name database shows undefined. think problem in success function. please me out.

<script> $(document).ready(function(){     $.ajax({         type: 'get',         url: 'connections/profile.php',         data: 'param=no' ,         atatype: "html",         success: function (response) {             console.log(response);                 $('#basiccontent').html('<h4><b>' + response.name + '</b></h4>');          },         error: function (e){             alert (e);         }      }); }); </script> 

also php

<?php require_once('connect.php'); session_start(); if (!isset ($_session['matric'])) { $go="index.html"; header("location:".$go); }  $matric = $_session['matric']; $pass= $dbh->prepare("select * users matric=:matric"); $pass->bindparam(':matric', $matric); $pass->execute(); $profile=$pass->fetch(pdo::fetch_assoc); $response = array( 'name' => $profile['name'], 'matric' => $matric, 'school' => $profile['school'] ); echo json_encode($response); 

change datatype html json

also in php file add header serve json content

header('content-type: application/json'); 

Comments