0

I'm trying to push ajax requests into a deferreds array, but I constantly get the following error:

Uncaught SyntaxError: missing ) after argument list

I've used this post as an example: Pass in an array of Deferreds to $.when()

Am I overlooking something really obvious?

<html>
<head>
<script src="https://code.jquery.com/jquery-2.2.2.js"></script>
<script src="../yajf.js"></script>
<script src="../yajf2.js"></script> 
</head>
<body>
    <script>
    var deferreds = [];
    $('script[src]').each(function() {
        var src = $(this).attr('src');
        deferreds.push(
            $.get(src,function(data){
                console.log(data);
            }); // error gets thrown on this line
        );
    });
    </script>
</body>
</html>
Community
  • 1
  • 1
BBQ.
  • 169
  • 11

1 Answers1

3

You've added a ; inside the (one-element) argument list for deferreds.push(). Remove the semicolon on that line.

    deferreds.push(
        $.get(src,function(data){
            console.log(data);
        }) // remove the semicolon from this line
    );

http://jslint.com

Blazemonger
  • 90,923
  • 26
  • 142
  • 180