I am trying to dynamically display data based on the selected value from a drop-down list using Ajax's GET method. The idea is to modify the URL by appending the selected item in order to retrieve relevant data from the server:
Here is an example of my code:
$.ajax({
type: 'GET',
url: 'url',
success: function(data) {
for (var i = 0; i < data.length; i++) {
$("#tbl2").append("<option>"+data[i]+"</option>");
}
}
});
var one = 'http://gate.atlascon.cz:9999/rest/a/';
var middle = $('#tbl2 :selected').text(); // This should be the selected item obtained from the previous GET call
var end = '/namespace';
var final_url = one + middle + end ;
$.ajax({
type: 'GET',
url: final_url,
success: function(data2) {
$("#text-area").append(data2);
}
However, this implementation does not seem to work as expected.
As I am new to programming, any assistance would be greatly appreciated. Thank you!