javascript - JS ajax - load more than one txt file in string - wrong order -


i have ajax request loads text files.

path like:

media/img/name1/desci.txt media/img/name2/desci.txt 

url : http://www.domain.com/media/img/"+sorttitles[i]+"/desci.txt

that returns txts in 1 div. don't want that. want place them content different divs. e.g. desc1 in div1...

here code. -> sorttitles[i] loads correct files.

    $.ajax({   url: "http://www.domain.de/chat/media/titles.txt",   datatype: "text",   scriptcharset: "iso-8859-1",   success: function(cats) {      sorttitles = cats.split('+++');     chatlength = sorttitles.length - 1;      (i = 2; < chatlength; i++) {        catholder = document.createelement('div');       catholder.setattribute("id", "cat" + + "");       catholder.setattribute("style", att1);        element = document.getelementbyid("categories");       element.appendchild(catholder);        catheadwr = document.createelement('div');       catheadwr.setattribute("id", "headwr");       catheadwr.setattribute("style", att3);       cathead = document.createelement('div');       cathead.setattribute("id", "head");       cathead.setattribute("onclick", "openshow('" + sorttitles[i] + "');");        cath2 = document.createelement('h2');       cath2.setattribute("id", "h22");       cath2.setattribute("style", att2);        cathimg = document.createelement('img');       cathimg.setattribute("id", "catbg");       cathimg.setattribute("src", "http://www.domain.com/media/img/" + sorttitles[i] + "/covr.jpg");        catdesc = document.createelement('div');       catdesc.setattribute("id", "desc" + + "");       catdesc.setattribute("style", attdesc);       cath2text = document.createtextnode("#" + sorttitles[i] + "");        element = document.getelementbyid("cat" + + "");       element.appendchild(catheadwr);       catheadwr.appendchild(cathead);       element.appendchild(catdesc);        $.ajax({         url: "http://www.domain.com/media/img/mediathek/" + sorttitles[i] + "/desci.txt",         datatype: "text",         success: function(data) {           i--;           document.getelementbyid("desc" + + "").innerhtml = data;          }       });        cathead.appendchild(cath2);       cathead.appendchild(cathimg);       cath2.appendchild(cath2text);      }   } }); 


Comments

Popular posts from this blog

java - Andrioid studio start fail: Fatal error initializing 'null' -

android - Gradle sync Error:Configuration with name 'default' not found -

StringGrid issue in Delphi XE8 firemonkey mobile app -