D
D
Doniyor Mamatkulov2018-02-21 22:49:51
JavaScript
Doniyor Mamatkulov, 2018-02-21 22:49:51

Why doesn't e.preventDefault() work?

Hey!
There is a drop down list on the page. I want to pull out the information from the database according to the ID with each selection of the item and issue it through alert.
My jQuery code:

$("#all-requests").on('change', function (e) {
        e.preventDefault();
        var pick = this.value;
        $.ajax({
            url:"/requests/get-request-desc",
            type: "GET",
            data: {id: pick},
            success:function(data) {
                alert(data);
            }
        });
    });

Now when you select an item from the dropdown, the page reloads and the necessary information is displayed, but the alert does not work. Tried putting preventDefault() in different places - doesn't work as it should...

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question