function retrieveHasilRawatJalan()
function retrieveHasilRawatJalan2(row, kd_klp) {
var hasil_rawat_jalan2;
var xhttp;
if (window.XMLHttpRequest) {
xhttp = new XMLHttpRequest();
} else {
// code for IE6, IE5
xhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (xhttp.readyState == 4 && xhttp.status == 200) {
hasil_rawat_jalan2 = JSON.parse(xhttp.responseText);
document.getElementById("type").innerHTML = "type of : " + typeof hasil_rawat_jalan2;
document.getElementById("value").innerHTML = "value of {'1' {'klp_id' : [" + hasil_rawat_jalan2[1]['klp_id'] + "]";
document.getElementById("size").innerHTML = "object size :[" + parseInt(Object.size(hasil_rawat_jalan2)) + "]";
document.getElementById("row_start").innerHTML = "start row : " + row;
document.getElementById("demo").innerHTML = "content : " + hasil_rawat_jalan2;
}
}
xhttp.open("POST", "../lab/get_row_content_from_lab_code/" + kd_klp + "", true);
xhttp.send();
//start from here the code is the same.
var number_of_row = parseInt(Object.size(hasil_rawat_jalan2));
addNewRow(number_of_row);
}
variable hasil_rawat_jalan2 contain JSON data and type of this variable is object,
i check type of variable hasil_rawat_jalan2, and call one of the data using this code
document.getElementById("type").innerHTML = "type of : " + typeof hasil_rawat_jalan2;
document.getElementById("value").innerHTML = "value of {'1' {'klp_id' : [" + hasil_rawat_jalan2[1]['klp_id'] + "]";
document.getElementById("size").innerHTML = "object size : [" + parseInt(Object.size(hasil_rawat_jalan2)) + "]";
document.getElementById("row_start").innerHTML = "start row : " + row;
document.getElementById("demo").innerHTML = "content : " + hasil_rawat_jalan2;
the result is this:
type of : object
value of {'1' {'klp_id' : [HL-004]
object size :[8]
start row : 1
content : [object Object]
the problem is when i put var number_of_row in function addNewRow() it doesnt do anything. but it work if i put number directly like this
addNewRow(8). how to check the error?
parseIntserves to parse a number from a string. Have you checked the contents ofnumber_of_rowat the call site ofadNewRow?xhttpafter theif/elseblock? The else becomes worthless (well they both do)