Skip to content

Instantly share code, notes, and snippets.

@eichgi
Created March 3, 2019 01:00
Show Gist options
  • Save eichgi/97692fb19ad9a210e2098a502d8b3aa7 to your computer and use it in GitHub Desktop.
Save eichgi/97692fb19ad9a210e2098a502d8b3aa7 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/axios/0.18.0/axios.min.js"></script>
<script>
//axios.get('http://patterns.test/practice/ajax/process.php')
axios.get('http://patterns.test/practice/ajax/json.js')
.then(function (res) {
console.log(res.data[1].name);
});
</script>
</body>
</html>
[{"name":"Hiram","age": "28"},{"name":"Eduardo","age":"34"}]
<?php
$array = [
[
'name' => 'Hiram',
'age' => 28,
],
[
'name' => 'Eduardo',
'age' => 34,
]
];
echo json_encode($array);
//[{"name":"Hiram","age":28},{"name":"Eduardo","age":34}]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment