Alex Batashov
Alex Batashov

Reputation: 289

Laravel's links inside JavaScript

I have link in my js:

 url: '/admin/products/ajax-remove-image/' + $('a.myimg').data('name'),

But after git clone from repositories this link not working because I must use like as:

url: '/public/admin/products/ajax-remove-image/' + $('a.myimg').data('name'),

How to make this dynamic ? I think this one:

  url: '{{url('/admin/products/ajax-remove-image/')}}' + $('a.myimg').data('name'),

But this part

    $('a.myimg').data('name') 

is not going together with main link.

Upvotes: 0

Views: 61

Answers (2)

Vildan Bina
Vildan Bina

Reputation: 330

put the script on public/assets folder and use {{ asset('your-filename.ext') }}

Upvotes: 0

Roberto Ferro
Roberto Ferro

Reputation: 427

You've to configure your virtual host to point on your_project/public directory. After all, you can use something like that:

let url = location.protocol + '//'+ window.location.hostname + '/admin/products/ajax-remove-image/' + $(a.myimg).data('name');

Upvotes: 1

Related Questions