I have a Drupal 8 form I want to show via JavaScript code to make it appear as a popup across multiple pages. The form is rendered through an AJAX response in a controller. I can see the response using $.ajax()
. How can I invoke the AJAX response to display on the page?
The JavaScript code is the following one.
$(document).ready(function() {
$.ajax({
url: '/aao_additions/modal_form',
// Data parameter is the ajax response data for the intersitial popup.
success: function(data, status, jqxhr) {
console.log(data);
console.log(status);
var popup = Drupal.ajax({
url: "",
base: false,
element: false,
progress: false,
});
// Simulate an AJAX response having arrived, and let the Ajax system handle it.
popup.success(data, "success");
},
// Error function for if the modal form cannot be loaded.
error: function(xhr, desc, err) {
console.log(xhr);
console.log("Desc: " + desc + "\nErr:" + err);
},
});
});
I receive an error on Drupal.ajax
. I think it is preventing the response rendering.