Javascript warning did not appear

I feel like I want me to ask this question. This is my first attempt at js (reason needed).
Why did I only see a warning Always

from all of them?

<script src="./js/jquery-1.11.2.min.js">alert("Never, but should it?");</script>
<script>alert("Always");</script>
<script>
    alert("Never");
    $(document).ready(function(){
        alert("Never");
        $('#send').click(function() {
            alert("Never");
            $.post('index.py', {document.getElementById('input_text').value}, function(data){
                alert("Never");
                $('loader').html(data);
            })
        })
    })
</script>

      

+3


source to share


2 answers


If you specify src

in a tag script

, then the javascript inside that tag will fail. After that, the first warning will be Always

, so you will see this specific warning

The third script contains a syntax error, so you don't see any warning Never

after clicking OK

in the messageAlways

Replace



$.post('index.py', {document.getElementById('input_text').value}, function(data){

      

from

$.post('index.py', document.getElementById('input_text').value, function(data){

      

+4


source


The first script contains an attribute src

that triggers the content.

From MDN :

This attribute specifies the URI of the external script; this can be used as an alternative to injecting the script directly inside the document. script elements with the src attribute specified must not have a script embedded in its tags

The third script fails because there is a syntax error.



Instead

$.post('index.py', {document.getElementById('input_text').value}, function(data){

      

you probably want

$.post('index.py', document.getElementById('input_text').value, function(data){

      

+3


source







All Articles