I am currently using ajax in a twig template. To call the url from ajax I am using a route. Here is the full ajax
$.ajax({
url: "{{ path_for('myfundrequest') }}",
type: 'get',
dataType: 'json'
}).done(function (response) {
var len = response.length;
fund.empty();
for (var i = 0; i < len; i++) {
var fundNum = response[i][0];
var fundName = response[i][1];
fund.append("<option value='" + fundNum + "'>" + fundNum + ' -- ' + fundName + "</option>");
}
fund.prepend("<option value=''>- Select A Fund -</option>").val('');
}).fail(function (jqXHR, textStatus, error) {
console.log("getFund: " + error);
});
});
If I move this to an external js file in my public folder how do I still call this the route in the url?
url: "{{ path_for('myfundrequest') }}"
Here is what my route looks like
$app->get('/fundrequest', 'PoEntryController:fund')->setName('myfundrequest');