K
K
k-22017-09-22 12:17:04
css
k-2, 2017-09-22 12:17:04

How to pass variable in ajax response?

for(..........count++){
  $("#result").append('<span id="'+count+'"></span>');
  $.post(
    "/method",
    {
      owner_id: count
    },	
    function(data){ 
// сюда надо вставить count значение которого было при вызове ajax
      $("#"+count).text(JSON.stringify(data));
    }
  );


How to remember count value when calling ajax?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Skibin, 2017-09-22
@K-2

Wrap everything in a loop in a closure

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question