The button has two onlick functions, but for some reason the error Unexpected end of input pops up.

Here is the button:

<div class="btn btn-v-1" style="margin-top:30px" type="text" onclick="SaveCountry();throw_message("Upload!")">Upload</div> 

Here are the functions:

 <script> function throw_message(str) { $('#error_message').html(str); $("#error_box").fadeIn(500).delay(3000).fadeOut(500); } </script> <script> function SaveCountry(){ var country = document.getElementById('country').value; $.ajax({ url: 'country.php', type: 'POST', data: {country:country}, success: function(res){ $('.alert').css('background',res.color) Alert_Opoveshenie(res.message); }, error: function(){ $('.alert').css('background','red') Alert_Opoveshenie('Error!'); } }); } 

    1 answer 1

    Quotes inside other quotes broke your html:

     function SaveCountry() { console.log("SaveCountry"); } function throw_message(aMessage) { throw aMessage; } 
     .btn { border:1px solid black; } 
     <div class="btn btn-v-1" style="margin-top:30px" type="text" onclick="SaveCountry();throw_message('Upload!')">Upload</div>