Can someone explain the difference between Ajax and rest? [closed]
I will not comment on your code in detail, but:
AJAX basically refers to making asynchronous request in JavaScript, traditionally sending/receiving XML (although nowadays, JSON is often used instead of XML).So that's the technique you use on client-side.
REST is a concept for HTTP request exchange, so you're making RESTful request calls (e.g. 'get') against the REST-API you implemented on server side.
See: Is AJAX a Rest api
And you might want read a little bit up about REST and AJAX on Wikipedia and other easy-to-access information sources.