使用jQuery的Ajax请求回调
**/*convertNum.php*/**$num = $_POST['json'];if (isset($num)) echo $num['number'] * 2;?><!DOCTYPE html><html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> <style type="text/css"> td {border:none;} </style> </head> <body> <table width="800" border="1"> <tr> <td align="center">Number To Send<br /><input type="text" id="numSend" size="40%" style="border:2px solid black;"></td> <td align="center">Number Returned<br /><input type="text" id="numReturn" size="40%" readonly></td> </tr> <tr><td align="center" colspan="4"><input type="button" value="Get Number" id="getNum" /></td></tr> </table> <script> $(document).ready(function () { $('#getNum').click(function () { var $numSent = $('#numSend').val(); var json = {"number":$numSent}; $.post("convertNum.php", {"json": json}).done(function (data) { alert(data); } ); }); }); </script> </body></html>
4<!DOCTYPE html><html><head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> <style type="text/css">td {border:none;}</style></head><body><table width="800" border="1"> <tr> <td align="center">Number To Send<br /><input type="text" id="numSend" size="40%" style="border:2px solid black;"></td> <td align="center">Number Returned<br /><input type="text" id="numReturn" size="40%" readonly></td> </tr> <tr><td align="center" colspan="4"><input type="button" value="Get Number" id="getNum" /></td></tr></table><script>$(document). ready(function () { $('#getNum').click(function () { var $numSent = $('#numSend').val(); var json = {"number":$numSent};
绝地无双
RISEBY