iframe式ajax调用示例
程序员文章站
2023-11-07 17:50:34
1.新建 a.html 复制代码 代码如下:
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
效果如图
下一篇: jquery网页效果开发入门教程