# Încărcarea datelor dintr-o rută Total.js cu AJAX

> Apelează o rută Total.js din pagină cu AJAX() și pune răspunsul în starea jComponent.

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

`AJAX('METHOD /url/', [data], callback)` trimite o cerere și apelează callback-ul cu răspunsul. Răspunsurile JSON sunt interpretate pentru tine. Combină-l cu `SET()` și orice `ui-bind` sau componentă legată de cale se actualizează singură.

```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>
```
