iframe式ajax调用示例
时间:2020-11-10 15:31:42|栏目:JavaScript代码|点击: 次
1.新建 a.html
<!doctype html>
<html>
<head>
<meta charset='utf-8'>
<title>iframe式ajax调用</title>
</head>
<body>
<form action='b.php' method='post' name='' id='' target='formTarget'>
<input type='text' name='username' id='' placeholder='' value='' />
<input type='submit' name='' value='提交' />
<span id='msg'></span>
</form>
<iframe src='' name='formTarget' id='formTarget' style='display:none'></iframe>
</body>
</html>
2.新建 b.php
<?php
echo "
<script>
parent.document.getElementById('msg').innerHTML = 'iframe式ajax调用成功!';
alert('您输入的是:{$_POST['username']}');
window.setTimeout(function(){
parent.window.location.reload();
},3000);
</script>
";
3.访问: http://localhost/a.html
效果如图
复制代码 代码如下:
<!doctype html>
<html>
<head>
<meta charset='utf-8'>
<title>iframe式ajax调用</title>
</head>
<body>
<form action='b.php' method='post' name='' id='' target='formTarget'>
<input type='text' name='username' id='' placeholder='' value='' />
<input type='submit' name='' value='提交' />
<span id='msg'></span>
</form>
<iframe src='' name='formTarget' id='formTarget' style='display:none'></iframe>
</body>
</html>
2.新建 b.php
复制代码 代码如下:
<?php
echo "
<script>
parent.document.getElementById('msg').innerHTML = 'iframe式ajax调用成功!';
alert('您输入的是:{$_POST['username']}');
window.setTimeout(function(){
parent.window.location.reload();
},3000);
</script>
";
3.访问: http://localhost/a.html
效果如图
栏 目:JavaScript代码
下一篇:基于BootStrap Metronic开发框架经验小结【七】数据的导入、导出及附件的查看处理
本文标题:iframe式ajax调用示例
本文地址:http://www.codeinn.net/misctech/20954.html