Option field on change Ajax post/get request

i have select tag and option fields (example jsfiddle). I want when user clicks on option, that some content (based on value) appear in collapse (like in View more button). If it possible, some Ajax get request will be good (i must send a option value), and i will provide data in backend. Iam very week on Ajax, and i did not even know how to begin.

Thanx

<select id="id_employees" name="employees">
<option value="" selected="selected">All</option>
<option value="4">Some text</option>
<option value="5">Some text1</option>
<option value="6">Some text2</option>
</select>

Answer

This should get you started:

$('#id_employees').change(function(e) {
    // e.target.value contains the selected value
    $.ajax({
        url: 'data-source.php',        
        success: function(data) {
            $('#id-of-container').append(data);

        }
    });
});

Leave a Reply

Your email address will not be published. Required fields are marked *