I’m using the ddslick jquery dropdown plugin in conjunction with my Rails app.
In view1, I have
$('#challenges_dropdown').ddslick({
<snipped>
onSelected: function (data) {
$.ajax({
url: "/load_data",
type: "GET",
data: {"id": data.selectedData.value}
});
}
});
I.e., I make a call to my controller to load_data. The controller receives this correctly and then at the end, makes a call to render a separate view
render "data.js"
This is a .js view that executes a script which updates some elements of my original view. For some reason, this script snippet is just not running.
I’m very confused. When I use a regular link with data-remote=”true”, then the whole process works perfectly. However, when I make an AJAX call, it fails.
Basically, I needed to specify a dataType for the AJAX call so that the response from the AJAX call would be seen as a script and thus executed: