javascript - Url error when js file is on public -
i make .js file in public folder on laravel, /assets/js/cms.js
i have code:
$(document).ready(function(){ listproject(); $("#buttoncreate").click(function(e){ $("#buttoncreate").remove(); e.preventdefault(); listuploadproject(); }); }); var listproject = function() { $.ajax({ type:'get', url:"{{ url('admin/project/listall') }}", success: function(data){ $('#ajaxwindow').empty().html(data); } }); } var listuploadproject = function() { $.ajax({ type:'get', url:"{{ url('admin/project/create') }}", success: function(data){ $('#ajaxwindow').empty().html(data); } }); }
and when view loaded, call url:
http://web.loc/admin/%7b%7b%20url('admin/project/listall')%20%7d%7d
and don't load listall , give me url error.
how fix it?
if need more info, please. appreciated help.
solved problem copy code blade .js script, can't put {{}} on url. looks this:
//javascript view /projects/menu.blade.php $(document).ready(function(){ listproject(); $("#buttoncreate").click(function(e){ $("#buttoncreate").remove(); e.preventdefault(); listuploadproject(); }); }); var listproject = function() { $.ajax({ type:'get', url:"/admin/project/listall", success: function(data){ $('#ajaxwindow').empty().html(data); } }); } var listuploadproject = function() { $.ajax({ type:'get', url:"/admin/project/create", success: function(data){ $('#ajaxwindow').empty().html(data); } }); }
seems blade not work inside double quotes. try doing way: {!! json_encode(url('admin/project/listall')) !!}
Comments
Post a Comment