简体   繁体   中英

Return bad Laravel token error in JSON?

I'm using Dropzone for multiple image uploads. If I get a server error that returns "Whoops, there's been an issue" the on-hover error message for that ajax upload flips out and tries to display the html for the entire page. What I need is for that page to return a json message instead. Is there a way for me to catch any errors that occur on upload failure?

you have to include the CSRF token. Normal jquery ajax can have this appended to header on body request parameter

$.ajax({
     type: "POST",
     url: "file",
     data: { 
        _token: $('input[name="_token"]').val()
     }
}).done(function( msg ) {
    console.log( msg );
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM