使用带链接的ajax将php页面结果加载到div中? [英] Load php page results into div with ajax with link?

查看:105
本文介绍了使用带链接的ajax将php页面结果加载到div中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试替换iframe。我想将php页面的结果加载到div中。结果通过网址进行解析 - http://example.com/view.php?id=1 - 例如。对不起,我对javascript没什么经验。

I am trying to replace an iframe, essentially. I would like to load the result of a php page into a div. The results are being parsed through URL - http://example.com/view.php?id=1 - for exmaple. Sorry, I don't have much experience with javascript.

我能找到的最接近的例子是: http://www.w3schools.com/PHP/php_ajax_database.asp

The closest example I could find is here: http://www.w3schools.com/PHP/php_ajax_database.asp

但这是一个选择框。

其他人可能吗?

推荐答案

如果你想用它作为链接那么懒惰解决方案是:

If you want to use it as a link then the lazy solution is:

<div id=content> loaded page goes here </div>

<a onclick="$('div#content').load('http://example.org/ajax.php?id=1')">click</a>

或者即使使用好的ol javascript伪URI:

Or even with the good ol javascript pseudo URI:

<a href="javascript:$('#id').load('url')">click</a>

这篇关于使用带链接的ajax将php页面结果加载到div中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆