我需要在laravel中执行AJAX请求,并且url是URL :: Action方法和Javascript整数变量之间的串联。URL :: action()和Javascript之间的连接int变量
视图中的javascript函数是
function detailMaintenanceVehicle(vehicleId,placa){
var url = "{{ URL::action('[email protected]',["+vehicleId+"]) }}";
console.log(vehicleId); // This prints integer variables 1,2,3..
console.log(url); // This prints a string http://localhost/.../detailMaintenance/+vehicleId+
$.ajax({
url: url,
dataType: 'json',
type: 'GET',
success: function(data) {
...
},
error: function(jqXHR, textStatus, errorThrown) {
...
}
});
}
级联中使用变量名,它必须使用的值。
//给出:http://localhost/.../detailMaintenance/+vehicleId+
//我需要:http://localhost/.../detailMaintenance/3(例如)
请帮助我。提前致谢!。
它的工作,并在短短一行VAR URL =( “{{...}}”)取代(..); –