Mitsubishi Electric MELSEC iQ-RJ71EN71 User Manual page 172

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

Advertisement

// The function for analyzing a response
function WriteDeviceBlockTbl_Response(xhr, typitem, dataitem) {
// 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 value;
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 write result value if the result is normal.
dataitem.value = parseInt(res.DATA[0],16);
alert("write complete");
}
}
</script>
</head>
<body>
<form>
<table id="devtbl" class="devtbl" border="1">
<tr>
<th>Device Name</th>
<th>Data Type</th>
<th>Value</th>
</tr>
<tbody>
<tr>
<td><input type="text" id="DEV1" name="DEV1" class="input" value="D10"/></td>
<td><input type="text" id="TYP1" name="TYP1" class="input" value="16-bit Integer"/></td>
<td><input type="text" id="DATA1" name="DATA1" class="input" value="3"/></td>
<td><input type="button" value=" Write" class="input" onclick="WriteDeviceBlockTbl('devtbl',1)"/></td>
</tr>
<tr>
<td><input type="text" id="DEV2" name="DEV2" class="input" value="D11"/></td>
<td><input type="text" id="TYP2" name="TYP2" class="input" value="32-bit Integer"/></td>
<td><input type="text" id="DATA2" name="DATA2" class="input" value="10"/></td>
<td><input type="button" value=" Write" class="input" onclick="WriteDeviceBlockTbl('devtbl',2)"/></td>
</tr>
<tr>
<td><input type="text" id="DEV3" name="DEV3" class="input" value="M0"/></td>
<td><input type="text" id="TYP3" name="TYP3" class="input" value="Bit"/></td>
<td><input type="text" id="DATA3" name="DATA3" class="input" value="1"/></td>
<td><input type="button" value=" Write" class="input" onclick="WriteDeviceBlockTbl('devtbl',3)"/></td>
</tr>
</tbody>
</table>
</form>
</body>
</html>
In the above example, the request parameter is as follows:
NUM=1&DEV1=D10&TYP1=D&DATA1=3
1 FUNCTIONS
170
1.12 Web Server Function

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents