ตัวอย่าง ของ เอแจ็กซ์

js.js

var xhr = XMLHttpRequest();//ประกาศ objectxhr.open("post", "data.php");//ดึงข้อความจาก data.phpxhr.send(null);//ไม่ต้องส่งข้อมูลไป ดึงแค่ข้อความalert(xhr.responseText);//จะ alert ว่า "This is Message."

data.php

<?PHPecho 'This is Message.';//แสดงผลคำว่า "This is Message." ด้วย function echo?>

jQuery example

$.ajax({    url: "data.php"//ดึงข้อความจาก data.php}).done(function(data){//เมื่อเสร็จแล้วให้นำข้อความที่ส่งกลับมาเก็บเอาใว้ในตัวแปร data    alert(data);//จะ alert ว่า "This is Message."});