Obtain dates with JavaScript before AJAX request

后端 未结 3 1478
误落风尘
误落风尘 2021-01-29 11:47

I have this AJAX request:

function request(str){
    

        
相关标签:
3条回答
  • 2021-01-29 12:24

    Try this:

    function form() {
        var id = document.getElementById('id').value;
        $("div2").text(id);
    }
    
    $(function() {
        $("#submit").click(function() {
          form();
        });
    });
    

    The syntax for embedding a function call in a jQuery event was incorrect. If you want to execute another function inside a jQuery function, you have to do the above, not .click(function form() {});

    0 讨论(0)
  • 2021-01-29 12:28

    I think this code is broken:

    <script>
        $(function() {
            $("#submit")
                .button()
                .click(function form() {
            });
        });
    
        function form(){
    
            var id = document.getElementById('id').value;
                    $("div2").text(id);
        }
    </script>
    

    Not sure that this will totally fix it but I think this is the right syntax:

    <script>
        $(function() {
            $("#submit")
                .button()
                .click(function() {
                     form();
            });
        });
    
        function form(){
    
            var id = document.getElementById('id').value;
                    $("div2").text(id);
        }
    </script>
    

    I don't think this will solve your problem though but that syntax you were using wasn't formed right. I think instead of calling the function like this:

    form();
    

    You may also be interested in looking at .trigger() or .call(), I also looked at the jquery documentation and I have never seen .button(), what is that for?

    0 讨论(0)
  • 2021-01-29 12:31

    I could be wrong but shouldn't the <script> tag come before the function?

    <script>    
    function request(str){    
        var aircraft = $("#div");
            aircraft.load("./file.php?icao="+str, function(){
            });
    }
    <script>
    
    0 讨论(0)
提交回复
热议问题