Why is the option select incorrectly selected when sending ajax?

  • 0
    There is a select with options
    <select id="sel">
                         <option value="1">опция 1</option>
                         <option value="2">Опция 2</option>
                         <option value="3">Опция 3</option>
                     </select>

    $.ajax({
                type: "POST",
                url: "/url/",
                data: {sel:$("#sel").val()},
    }

    On the server side, for some reason, regardless of which option is selected, only the value of the first comes to the select. How do I get the correct value for the select?
    AJAX Emerson Sanders, Dec 2, 2020

  • 1 Answers
  • 0
    $('.sel').change(function(){
    // тут получаете значение option и в ajax его
    })
    Hunter McKee

Your Answer
To place the code, please use CodePen or similar tool. Thanks you!