I am attempting to create/read nodes from a JS file (the nodes are created in response to Js events from a library). The PHP functions to create/read the nodes have been created and require field data as parameters. How can I run these functions from a JS file and pass the required data as parameters? I am willing to relocate/rewrite the functions in a new PHP file if required.
- I cannot use routing/controllers/API endpoints as I would need to pass parameters as slugs - some parameters are strings and may contain slashes which are not supported by routing
- The generation and submission of data is based on a JS library rather than Drupal forms, so I cannot use Drupal Ajax forms and pass my parameters through that. Without forms, Ajax callbacks have no support for parameters.
- I am not sure if this Ajax request is an option with Drupal - if it is, how would I structure the 'url' in the Ajax request to get a certain php file from my module?