最简单的方法是使用像 jQuery 这样的库,而不是自己动手......
<head>
<script src="http://code.jquery.com/jquery.min.js">
....
然后在您计算数据时,将其发布到 PHP 服务器
var OUT = new Array (0x80,0x00,0x40,0x0026,0x0011,0x0014,0x0013,0x0018,0x0017,0x03FD,0x0116);
$.ajax({
url: 'http://www.example.com/receiver.php' //change example.com to your server
,type: 'POST' //use POST so don't have to worry about URL length
,data: {out: OUT} //pass contents of 'OUT' in variable 'out'
,dataType: 'json' //use JSON formatting of data
,error: function() {
alert("Failed to contact server");
}
,complete: function() {
alert("Finished sending data to server.");
}
});
在receiver.php
$OUT = json_decode( $_POST['out'] ); // 'out' matches the parameter name in jQuery Ajax call
print_r( $OUT ); //print contents of array $OUT