Skip to content

Instantly share code, notes, and snippets.

[
{"alias": "all", "cat": "All Departments"},
{"alias": "mobile-apps", "cat": "Apps & Games"},
{"alias": "baby", "cat": "Baby"},
{"alias": "beauty", "cat": "Beauty"},
{"alias": "books", "cat": "Books"},
{"alias": "automotive", "cat": "Car & Motorbike"},
{"alias": "popular", "cat": "CDs & Vinyl"},
{"alias": "classical", "cat": "Classical Music"},
{"alias": "clothing", "cat": "Clothing"},
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset='UTF-8'>
<title>AJAX Select from JSON example</title>
</head>
<body>
<select id="category-dropdown" name="category">
</select>
</body>
<?php
print_r($_REQUEST);
?>
!DOCTYPE html>
<html>
<head>
<title>AJAX HTML input value Example</title>
<style>
textarea {
outline: none;
resize: none;
width: 400px;
height: 400px;
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>A basic AJAX example using a Promise</title>
</head>
<body>
function getDataFromServer() {
return new Promise((resolve, reject) => {
// make an Ajax request to the server
let xhr = new XMLHttpRequest();
xhr.open('GET', 'http://localhost/ws11/books.xml');
// handle the response
xhr.onload = () => {
if (xhr.status === 200) {
// if the request is successful, resolve the promise with the response data
resolve(xhr.response);
<?xml version="1.0"?>
<books>
<book id="bk101">
<author>Gambardella, Matthew</author>
<title>XML Developer's Guide</title>
<genre>Computer</genre>
<price>44.95</price>
<publish_date>2000-10-01</publish_date>
<description>Creating applications with XML.</description>
</book>
<!DOCTYPE html>
<html>
<head>
<title>AJAX pull XML Example</title>
<style>
textarea {
outline: none;
resize: none;
width: 400px;
height: 200px;
<?php
# set timezone
@date_default_timezone_set("GMT");
# Set CONSTANTS
# set the base rate
define('BASE', 'GBP');
# set the intial live currency codes
define ('LIVE', array(
id|quote|source|dob|dod|wplink|wpimg|category
1|I shall tell you a great secret, my friend. Do not wait for the last judgment. It takes place every day.|Albert Camus|1913|1960|https://en.wikipedia.org/wiki/Albert Camus|https://upload.wikimedia.org/wikipedia/commons/0/08/Albert_Camus%2C_gagnant_de_prix_Nobel%2C_portrait_en_buste%2C_pos%C3%A9_au_bureau%2C_faisant_face_%C3%A0_gauche%2C_cigarette_de_tabagisme.jpg|politics, philosophy
2|Dear Mrs. Chown, Ignore your son's attempts to teach you physics. Physics isn't the most important thing. Love is. Best wishes, Richard Feynman.|Richard Feynman|1918|1988|https://en.wikipedia.org/wiki/Richard_Feynman|https://upload.wikimedia.org/wikipedia/en/4/42/Richard_Feynman_Nobel.jpg|science, love
3|I think I can safely say that nobody understands quantum mechanics.|Richard Feynman|1918|1988|https://en.wikipedia.org/wiki/Richard_Feynman|https://upload.wikimedia.org/wikipedia/en/4/42/Richard_Feynman_Nobel.jpg|science,humour
4|Science may set limits to knowledge, but should not