我需要在鼠标停机和鼠标启动时使用两个不同的参数运行php。我怎样才能做到这一点?
谢谢。
我有这个HTML:
<script src="jquery.js"></script>
<script src="jquery.form.js"></script>
<script>
$(document).ready(function() {
$('#mbed').ajaxForm(function() {});
});
</script>
</head>
<body>
<form id="mbed" target="_blank" action="mbed.php" method="post">
<input type="submit" name="increment" value="Faster">
<input type="submit" name="decrement" value="slower">
和这个文件 - mbed.php:
<?php
if(isset($_POST['increment'])) {
$sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
$msg = "FF0100";
$len = strlen($msg);
socket_sendto($sock, $msg, $len, 0 ,'192.168.1.199', 12345);
socket_close($sock);
}
if(isset($_POST['decrement'])) {
$sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
$msg = "FF0101";
$len = strlen($msg);
socket_sendto($sock, $msg, $len, 0 ,'192.168.1.199', 12345);
socket_close($sock);
}
?>
答案 0 :(得分:0)
我认为可以通过ajax
$("#mbed").mouseup(function(){
$.ajax({url:"mousedown.html",tpye:"POST",data:"your data",success:successFunc()})
}).mousedown(function(){
$.ajax({url:"mousedown.html",tpye:"POST",data:"your data",success:successFunc()})
})