您的位置:首页 > 编程语言

iframe式ajax调用示例代码

2018-10-12 14:08 232 查看

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

您可能感兴趣的文章:

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: