2

I want to display the value based on selected value on drop down list with using Get method of Ajax from the url,

based on schema i have to add the value of selected item to the meddle of url and then i can get the relative data from the server:

this is 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(); // it should be the selected item from last get method
var end = '/namespace';
var url_t = one + middle + end ;


$.ajax({
   type: 'GET',
   url: url_t,
   success: function(data2) {
   $("#text-area").append(data2);
   }

but it is not work!

i am new in programming, could you please help me. thanks.

2 Answers 2

1

try this:

$.ajax({
   type: 'GET',
   url: 'url',
   success: function(data) {

   for (var i = 0; i < data.length; i++) {
        $("#tbl").append("<tr><td>"+data[i]+"</td></tr>");
     }
   }
});
Sign up to request clarification or add additional context in comments.

2 Comments

is this answer is useful?
yes, thanks. know i have a error 405, with sending data by post method do you know how to solve it?
0

Add this in your ajax success():

data.forEach(function(item) {
  $("#tbl").find('tbody')
      .append($('<tr>')
          .append($('<td>').text(item))
      );
})

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.