0

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.

2
  • 1
    Is it possible you need to add the / back in, the one between the path and the $ part? What does the code look like in the browser? Commented Jul 10, 2019 at 10:19
  • it`s work for me ! I just added ' / ' between url() and $ like: url: '{{url('/admin/products/ajax-remove-image')}}'+ '/' + $('a.myimg').data('name') Thx ! Commented Jul 10, 2019 at 10:26

2 Answers 2

1

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');
Sign up to request clarification or add additional context in comments.

Comments

0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.