2

I tried to access variable inside blade syntax:

            success: function(resp) {
                console.log(resp)
                var MsgClass = 'alert-danger';
                $("#overlay").hide();
                if(resp.success) {
                    MsgClass = 'alert-success';
                    window.location.href = "{{ asset('public/exports/'+resp.filename) }}"
                }                    
            },

But I get

Use of undefined constant resp - assumed 'resp'

How can I get this variable inside the syntax?

1
  • 2
    {{ asset('public/exports/') }} + resp.filename Commented May 13, 2020 at 16:16

1 Answer 1

2

Just use like this

window.location.href = '"{{url('')}}/public/exports/"'+resp.filename
Sign up to request clarification or add additional context in comments.

1 Comment

That +'}}"' at the end shouldn't be required.

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.