I'm writing for loop to show created links and using this loop:
for (var x = 0; x < data.succeeded.length; x++) {
$.post("{{URL::action('make')}}", {url: "{{URL::route('home')}}/uploads/" + data.succeeded[x].file, name: data.succeeded[x].name}, function(url) {
anchor = document.createElement('a');
anchor.href = url;
anchor.target = '_blank';
anchor.innerHTML = x + ' ' + data.succeeded[x].name + '<br><small>(' + url + ')</small>';
succeeded.appendChild(anchor);
});
}
but in $.post
function url name (data.succeeded[x].name
) allways stay the same only url updates. But if I use console.log on 2nd line (after for() {
) url name changing as it should.
What did i wrong?