I tested this on Google Chrome browser.
script.js
AJAX request uses XMLHttpRequest object. It is well explained here
var a = "bully";
var b = "burger";
var url = 'process.php?a=' +a+ '&b=' +b;
console.log('sending request ...');
var xhr = new XMLHttpRequest(); // create the object
// ajax on load
xhr.addEventListener('load', function(e) {
console.log('Response loaded: ' +this.responseText);
document.body.innerHTML = this.responseText;
// change the url on the address bar
// pushState(object or string, title, newUrl)
window.history.pushState({a: a, b: b}, 'Title: ' +a+ ' ' +b, '?a=' +a+ '&b=' +b);
}, false);
// ajax on error
xhr.addEventListener('error', function(e) {
console.log('Failed to load the response.');
document.body.innerHTML = 'Failed to load the response.';
}, false);
// open(method, url, isAsynchronous). Should be called after we set all events.
xhr.open('GET', url, true); // open the connection.
xhr.send(); // send the request.
index.html
Just include the javascript file to do AJAX request.
<!DOCTYPE html>
<html>
<head>
<title>Demo</title>
<script src="script.js"></script>
</head>
<body>
</body>
</html>
process.php
This script gets the parameters sent by the javascript.
<?php
$a = $_GET['a'];
$b = $_GET['b'];
echo $a. ' ' .$b;
P.S. Edited
Add window.history.pushState() in "load" event to update/change the current url on address bar. See here and here