脚本宝典收集整理的这篇文章主要介绍了php – jQuery – 如何在另一个页面中填充div,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
<form id="test" action="#" method="post"> <input tyPE="text" name="user"/> <input type="submIT" name="LOGin" value="login"/> </form>
user.PHP的
<?PHP echo "Hello,".$_POST['user']; ?>
的index.html
<body> <div id="target"></div> </body>
最终结果(index.html)
“你好,John Doe”
$('#test').submit(function() { $('index.html#target').load('user.PHP'); });
如果你想从user.PHP获取id为target的div,请使用以下代码:
$('#target').load('user.PHP #targer');
但您可能想发送帖子请求?
$.post('user.PHP',$('form').serialize(),function(data){ $("#target").html(data) });
要学习的东西:
> http://api.jquery.com/serialize/
> http://api.jquery.com/jQuery.post/
> http://docs.jquery.com/How_jQuery_Works
以上是脚本宝典为你收集整理的php – jQuery – 如何在另一个页面中填充div全部内容,希望文章能够帮你解决php – jQuery – 如何在另一个页面中填充div所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。