Posts in: Javascript

Prevent Double Submit with JavaScript

0 comments / July 29, 2019

Assume you got this form <form action=”/insert_2000_rows_now” method=”POST”> <button>Submit<button> </form> which inserts on submits 2000 rows. It could happen that on double click 4000 rows are inserted. That is bad.

Ajax not working in Laravel?

0 comments / June 29, 2019

Assume you have a list of items with checkboxes: <ul class=”project-ul”> @foreach ($projects as $project) <li> <label><input type=”checkbox” value=”1″ class=”checking” data-id=”{{$project->id}}” {{($project->featured) ? ‘checked’ : ”}}> {{$project->title}}</label></li> @endforeach </ul> This may return a list like this:

Warn user when he leaves page

0 comments / June 7, 2019

You can create a pop-up that asks the user if he is sure that he wants to leave the page. This is used on Gmail, Facebook, Twitter, Stackoverflow, LinkedIn, etc., in all pages where you might lose data, if you accidentally close the tab.