user5473154
user5473154

Reputation: 27

jquery, node - more than one get request

I am trying to add another get request.

In my html

    $(document).ready(function(){
        $("#submit-button-one").click(function(){
            var searchField = $("#searchField").val();
            $.get("http://localhost:3000/searching", {
                searchField: searchField
            }, function(data){
                // display results and reveal submit-button-two
            });
        });

        $("#submit-button-two").click(function(){
            var selectedItem = $('input[name = item]:checked').val();
            alert(selectedItem);

            // ^everything above works without the code below

            $.get("http://localhost:3000/submit-item", {
                selectedItem: selectedItem
            }, function(data){
                alert(data);
            }
        });
    });

When I add in the code for the second get request, the first one stops working and clicking submit-button-one doesn't do anything anymore.

Any help/links would be great! thanks

Upvotes: 0

Views: 23

Answers (1)

Erik Engervall
Erik Engervall

Reputation: 269

You're missing a parenthesis on the last $.get.

$(document).ready(function(){
    $("#submit-button-one").click(function(){
        var searchField = $("#searchField").val();
        $.get("http://localhost:3000/searching", {
            searchField: searchField
        }, function(data){
            // display results and reveal submit-button-two
        });
    });

    $("#submit-button-two").click(function(){
        var selectedItem = $('input[name = item]:checked').val();
        alert(selectedItem);

        // ^everything above works without the code below

        $.get("http://localhost:3000/submit-item", {
            selectedItem: selectedItem
        }, function(data){
            alert(data);
        });
    });
});

Upvotes: 1

Related Questions