Azima
Azima

Reputation: 4141

laravel blade variable inside javascript

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?

Upvotes: 2

Views: 45

Answers (1)

A.A Noman
A.A Noman

Reputation: 5270

Just use like this

window.location.href = '"{{url('')}}/public/exports/"'+resp.filename

Upvotes: 2

Related Questions