Cannot get the value from Javascript object converted from json response?
<p>I have no idea how to fix it. The value that i got is always"undefined" even when the response i get and I show by alert Here is my ajax code and two picture that I collected from my result. one when I show the json response and another when I show the json property
<hr>
when </p>

<pre><code>alert(json_data).
</code></pre>

<p><a href="https://i.stack.imgur.com/svYyF.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/svYyF.jpg" alt="enter image description here"></a></p>

<p><hr>
when </p>

<pre><code>alert(json_data.status)
</code></pre>

<p>, it shows "undefined"
<a href="https://i.stack.imgur.com/3AfdP.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3AfdP.jpg" alt="enter image description here"></a></p>

<p>ajax code:</p>

<pre><code> $("#input-form").submit(function(e) {
    var test = checkFile();
    var file_data = $('#imgInpbanner').prop('files')[0];
    var form_data = new FormData();
    if (test == true) {
        form_data.append('avatar', file_data);
    }
    form_data.append('_token', $('#_token').val());
    form_data.append('experient_period', $("#experient-period").val());
    form_data.append('married', $("#married").val());
    form_data.append('acc_id', &lt;?php echo $teacher-&gt;acc_id; ?&gt;);
    form_data.append('official_staff', $("#official_staff").val());
    form_data.append('certificate', $("#certificate").val());
    form_data.append('birth', $("#birth").val());
    form_data.append('beginning_date', $("#beginning-date").val());
    form_data.append('gender', $("#gender").val());
    form_data.append('user_name', $("#user_name").val());
    form_data.append('email', $("#email").val());
    form_data.append('password', $("#password").val());
    form_data.append('first_name', $("#first_name").val());
    form_data.append('last_name', $("#last_name").val());
    form_data.append('phone_number', $("#phone_number").val());
    form_data.append('address', $("#address").val());
    form_data.append('colleague', $("#colleague").val());
    var formURL = $(this).attr("action");
    $.ajax({
        url: formURL,
        dataType: 'text', // what to expect back from the PHP script, if anything
        cache: false,
        contentType: false,
        processData: false,
        type: "POST",
        data: form_data,
        success: function(data, textStatus, jqXHR) {
            //data: return data from server
            var json_data = JSON.parse(JSON.stringify(data));
            alert(json_data.status);
            if (json_data.status == 200) {
                $('#modal-header').css('background-color', '#00c0ef');
                $('#result_inform').text(json_data.message);
                $('#modaltest').trigger("click");
            } else {
                $('#modal-header').css('background-color', '#d33724');
                $('#result_inform').text(json_data.message);
                $('#modaltest').trigger("click");
            }
        },
        error: function(jqXHR, textStatus, errorThrown) {
            //if fails
            $('#modal-header').css('background-color', '#d33724');
            $('#result_inform').text("Có lỗi xảy ra");
            $('#modaltest').trigger("click");

        }
    });
    e.preventDefault(); //STOP default action
    e.unbind(); //unbind. to stop multiple form submit.
});
</code></pre>

<p>PHP controller</p>

<pre><code> $isOldPw = strcmp(Input::get('password'), '');
    $acc_id = Input::get('acc_id');
    try {
        $teacher = Teachers::findOrFail($acc_id);
        $user = Users::findOrFail($acc_id);
        $isOldEmail = strcmp(Input::get('email'), $user - &gt; email);
        $isOldUrNm = strcmp(Input::get('user_name'), $user - &gt; user_name);
        $rules = array(
            'first_name' =&gt; 'required|max:10',
            'last_name' =&gt; 'required|max:30',
            'address' =&gt; 'required|max:100',
            'phone_number' =&gt; 'required|max:15|regex:/(0)[0-9]{9}/',
            'user_name' =&gt; 'required|min:5|unique:user',
            'email' =&gt; 'required|email|unique:user',
            'password' =&gt; 'required|min:6'
        );
        if ($isOldPw == 0) array_splice($rules, 6, 1);
        if ($isOldEmail == 0) array_splice($rules, 5, 1);
        if ($isOldUrNm == 0) array_splice($rules, 4, 1);
        $validator = Validator::make(Input::all(), $rules);
        if ($validator - &gt; fails()) {
            $messages = $validator - &gt; messages();
            return response() - &gt; json(['status' =&gt; 400, 'message' =&gt; $messages - &gt; toJson()]);
        } else {
            $user - &gt; user_name = Input::get('user_name');
            $user - &gt; first_name = Input::get('first_name');
            $user - &gt; last_name = Input::get('last_name');
            $user - &gt; email = Input::get('email');
            $user - &gt; address = Input::get('address');
            $user - &gt; phone_number = Input::get('phone_number');
            if ($isOldPw != 0)
                $user - &gt; password = Hash::make(Input::get('password'));
            $user - &gt; gender = (Input::get('gender'));
            $user - &gt; birth = date('Y-m-d', strtotime(Input::get('birth')));
            $teacher - &gt; certificate = (Input::get('certificate'));
            $teacher - &gt; beginning_time = date('Y-m-d', strtotime(Input::get('beginning_date')));
            $teacher - &gt; colleague = (Input::get('colleague'));
            $teacher - &gt; official_staff = (Input::get('official_staff'));
            $teacher - &gt; married = (Input::get('married'));
            $teacher - &gt; experient_period = (Input::get('experient_period'));

            if (Request::hasFile('avatar') &amp;&amp; Input::file('avatar') - &gt; isValid()) {
                if (strlen($user - &gt; image_url) &gt; strlen(SysConst::get('DEFAULT_AVATAR_PATH')))
                    File::delete(public_path().$user - &gt; image_url);
                $img_path = SysConst::get('IMAGE_PATH_USERAVATAR');
                $file = Input::file('avatar');
                $image_name = time().
                '-'.$file - &gt; getClientOriginalName();
                $file - &gt; move(public_path().$img_path, $image_name);
                $image_alter = Image::make(sprintf(public_path().$img_path.
                    '%s', $image_name)) - &gt; resize(128, 128) - &gt; save();
                $image_url = $img_path.$image_name; // Note we add the image path to the databse field before the save.
                $user - &gt; image_url = $image_url;
            } else {
                $user - &gt; image_url = SysConst::get('DEFAULT_AVATAR_PATH');
            }
            DB::beginTransaction();
            $user - &gt; save();
            $teacher - &gt; acc_id = $user - &gt; id;
            $teacher - &gt; save();
            DB::commit();
            return response() - &gt; json(['status' =&gt; 200, 'message' =&gt; 'Cập   nhật thành công']);
        }
    } catch (\PDOException $ex) {
        DB::rollBack();
        return response() - &gt; json([
            "status" =&gt; 500,
            "message" =&gt; $ex - &gt; getMessage()
        ]);
    } catch (\Exception $ex) {
        return response() - &gt; json(['status' =&gt; 400, 'message' =&gt; $ex - &gt; getMessage()]);
    }
</code></pre>