Trying Use Ajax Incorporate Json Php Jquery Personalinfophp Ajax Json Php Jquery 21 Email Q29264336

I am trying to use AJAX and incorporate JSON, PHP andjQuery….

Personal_Info.php

<!DOCTYPE html>
<html>
<head>
<meta charset=”utf=8″>
<title>AJAX, JSON, PHP, and jQuery</title
<script type=”text/javascript”src=”js/jquery.min.js”></script>
<script type=”text/javascript”src=”js/JSON.js”></script>
</head>
<body>
<div id=”loading”>Loading</div>
<div id=”result”></div>
</body>
</html>

data.php

<?PHP

$about = array(
    ‘name’ => ‘Deanna Medeiros’,
    ‘age’ => 21,
    ’email’ => ‘dee@aol.com’

);

$about2 = array(
    ‘name’ => ‘John Doe’,
    ‘age’ => 31,
    ’email’ => ‘jdoe@aol.com’

);

    $array =array($about,$about2);
    echo json_encode($array);
?>

JSON.js

$(document).resdy(function(){
$(‘#loading’).click(function(){
   $.ajax({
     type: ‘POST’,
    url: ‘data.php’,
    dataType: ‘json’,
    success: function(data){
       $(‘#result’).append(‘<p>Name: ‘ + data.name + ‘<br/> Age: ‘ + data.age + ‘<br/>Email: ‘ + data.email + ‘</p>’);
       
    }
   });
});
});

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published.