# Load data from a Total.js route with AJAX

> Call a Total.js route from the page with AJAX() and put the response into the jComponent state.

Framework: jcomponent20
Product: jComponent 20 (jcomponent@20)
Language: en
Content-SHA256: 72d9f15885081fa9a0eb755ef2c0e76646960a862b815ae9cf970b6cdb2de691
Snapshot: c0700e321579725c5cf4f5ace1ad7d2866d1b4f93c24a63c0b41b6b7998e976c
Sources: jcomponent20@3fedd009a277f50fddc608b97afbec553b67c51b
Review: not-recorded

`AJAX('METHOD /url/', [data], callback)` sends a request and calls the callback with the response. JSON responses are parsed for you. Combine it with `SET()` and any `ui-bind` or component bound to the path updates by itself.

```js controllers/api.js
exports.install = function() {
	ROUTE('GET /api/hello/', hello);
};

function hello($) {
	$.json({ message: 'Hello from Total.js' });
}
```

```html public/index.html
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8" />
	<title>jComponent</title>
	<link rel="stylesheet" href="//cdn.componentator.com/spa.min@20.css" />
	<script src="//cdn.componentator.com/spa.min@20.js"></script>
</head>
<body>

	<p><ui-bind path="greeting" config="text:value">Loading...</ui-bind></p>

	<script>
		AJAX('GET /api/hello/', function(response) {
			SET('greeting', response.message);
		});
	</script>

</body>
</html>
```
