[Solved] jQuery, getting “500 Internal Server Error” when running a jQuery statement


In order to achieve what you want this will do the job:

<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script>
    $(document).ready(function() {
         $('#myButton').on('click',function(){
            alert("i clicked it");
          });
    });
</script>
</head>
<body>
    <button id="myButton">Click Me!</button>
</body>
</html>

$(document).ready is used to execute your code just after your page is rendered, then $('myButton') will get any element with an id “myButton”, then you will use the method “on” to attach any event you want, in this case you will want to choose the “click” event, then you should give an anonymous function where you will put the code you would like to execute on that action.

5

solved jQuery, getting “500 Internal Server Error” when running a jQuery statement