Mitsubishi Electric MELSEC iQ-RJ71EN71 User Manual page 166

Ethernet
Hide thumbs Also See for MELSEC iQ-RJ71EN71:
Table of Contents

Advertisement

// The function for analyzing a response
function ReadDeviceRandomTbl_Response(xhr, devtblid) {
// XMLHttpRequest Client status check
// 0:UNSENT 1:OPENED 2:HEADERS_RECEIVED 3:LOADING 4:DONE
if( 4 != xhr.readyState ) {
// End the processing if the status 4 is other than DONE (operation complete).
return;
}
// HTTP Response code check
if ( 200 != xhr.status ) {
// Display the error dialog box if the response code is other than "200 OK".
alert("HTTP STATUS ERROR=" + xhr.status );
return;
}
var i, dataitem;
var devtblitem = document.getElementById(devtblid);
var tblrows = devtblitem.rows.length; // Obtain the number of the table lines (including the header).
var res = JSON.parse( xhr.response ); // Analysis processing of JSON string
// Judgment from the CGI
if( res.RET != "0000" ) {
// Display the error dialog box if the result is abnormal.
alert("ERROR=" + res.RET);
}
else {
// Reflect the obtained value to the table if the result is normal.
for ( i = 1, m = 0; i < tblrows; i++, m++) {
dataitem = document.getElementById(devtblitem.rows[i].cells[2].childNodes[0].id);
// Set the read result to the value of the table (convert the hexadecimal string to numerical value).
dataitem.value = parseInt(res.DATA[m],16);
}
alert("read complete");
}
}
</script>
</head>
1 FUNCTIONS
164
1.12 Web Server Function

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents