Updating entities/posting data via ajax?
The AJAX callback URL will be a route you define in a module. The route will call a controller, which can optionally return an AjaxResponse. First define the route.

example.routing.yml:

example.ajax_callback:
  path: '/example/ajax'
  defaults:
    _controller: '\Drupal\example\Controller\AjaxController::ajaxCallback'
  requirements:
    _permission: 'some permission'


The path to set in your $.ajax() call is set above.

Then create the controller:

example/src/Controller/AjaxController.php:

namespace Drupal\example\Controller;

use Drupal\Core\Ajax\AjaxResponse;
use Drupal\Core\Controller\ControllerBase;

class AjaxController extends ControllerBase {

  public function ajaxCallback($nid, $key, $value) {
    $node = \Drupal::entityTypeManager()-&gt;getStorage('node')-&gt;load($nid);
    $node-&gt;set($key, $value);

    return new AjaxResponse(['success' =&gt; TRUE]);
  }
}