jeudi 3 octobre 2019

null is not an object (evaluating 'document.getElementById('logout-form').submit') - Why am I getting this error?

I'm setting up authentication in my Laravel app, I can login and authenticate without issue, but when I click the logout link nothing happens. I am not redirected, I just get this JavaScript error:

TypeError: null is not an object (evaluating 'document.getElementById('logout-form').submit')

I've tested in Safari and Chrome and the behaviour is identical. I'm sure I'm just doing something stupid, and I'm not a professional developer.

<a class="dropdown-item" href="#" onclick="event.preventDefault();document.getElementById('logout-form').submit();">Logout</a>
<form id="logout-form" action="" method="POST" style="display: none;">@csrf</form>

I'm not clear on why this is not triggering. Help?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire