html+js
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>将数组的数据循环遍历到HTML中</title>
</head>
<body>
<div id="LoveID">
<form id="form1" action="a.php" enctype="multipart/form-data" method="post">
<table>
<tr>
<td>请输入文字:</td>
<td><input type="text" name="wenzi"/></td>
</tr>
<tr>
<td><input type="submit" name="submit" value="提交"/></td>
<td><input type="reset" name="reset" value="重置"/></td>
</tr>
</table>
</form>
</div>
</body>
<script src="https://upcdn.b0.upaiyun.com/libs/jquery/jquery-2.0.2.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.form/4.2.1/jquery.form.min.js" integrity="sha384-tIwI8+qJdZBtYYCKwRkjxBGQVZS3gGozr3CtI+5JF/oL1JmPEHzCEnIKbDbLTCer" crossorigin="anonymous"></script>
<script>
$(document).ready(function()
{
$("#form1").ajaxForm(function (data) {
alert(data);
console.log(data);
console.log("str:" + JSON.stringify(data));
}
);
});
</script>
</html>
a.php
<?php
$wenzi= $_REQUEST['wenzi'];
echo $wenzi;
?>
结果:
|