0

I have this AJAX call:

<script type="text/javascript">
    $(document).ready(function() {

        $.ajax({
                url:'test.php',
                type:'GET', 
                datatype: "json",
                success:function(data)
                {
                    alert(data);
                },
                error:function()
                {
                    alert("error");
                }
            });
    });
</script>

and my test.php contains this:

<?php
    echo json_encode("pepperoni pizza");
    exit;
?>

However, my alert ends up showing all the PHP code instead of just "pepperoni pizza"

I have looked around quite a bit but haven't found a post that completely solves my problem. Thanks in advance for any tips!

  • Is that test.php being loaded when ypu are reading it via browser ? That going to test.php in url bar ? – frunkad Feb 11 '15 at 19:52

1 Answers1

0

It sounds like your web server is not configured to use PHP for interpretation of .php files.

Mike Brant
  • 70,514
  • 10
  • 99
  • 103