PHP ve jQuery en json

0 Cevap php

Benim html dosyası:

    <script>
    $(document).ready(function() {  
        $.ajax({
            type: "POST",
            url: "search.php",
            data: "id=1",
            datatype: "json",
            success: function(msg){
                $('.result1').html(msg["name"]);
            }
        });  
    })
    </script>   

    <span class="result1"></span>

My php file:

    <?
    $a["name"] = 'john';
    echo json_encode($a);
    ?>

Why the name John doesn't appear in class result1? Why? Please help me, I am going insane.

edit: Is it possible to make bounty right now?

0 Cevap