javascript - Database every row in different div -


i try make every row in database different div. doesn't work when try run it, gives me 2 letters. checked php , works correctly.

var request = new xmlhttprequest; request.open('get' , 'myurl', false); request.send(); console.log(request);  if (request.status == 0) console.log(request.responsetext);  var firstname, lastname; var obj = json.parse(request.responsetext); console.log(obj);  (var = 0; i<obj.length; i++){     firstname = obj[i].firstname;     lastname = obj[i].lastname;      console.log(firstname,lastname);      var divelement = document.createelement("div");       divelement.id = "mydiv";        divelement.classname = "mydivclass";       divelement.innerhtml = firstname[i] + " " + lastname[i];     document.body.appendchild(divelement);     } 

you seem writing elements based on loop.

why doing

 divelement.innerhtml = firstname[i] + " " +  lastname[i]; 

when needs be

 divelement.innerhtml = firstname + " " +  lastname; 

Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -