2012-08-04 73 views
0

我正在做一个小小的管理面板,想知道是否有可能在点击面板中的按钮以在jQuery中添加index.php文件中的div框?jQuery将div添加到另一个页面

如果是这样,一个小例子将不胜感激!

+1

谷歌会很快回答这个问题。 – 2012-08-04 15:25:56

回答

0

您需要使用jQuery的$.post()方法来发送XML HTTP POST请求,然后在服务器上的PHP文件修改索引文件,或可包含在索引中的文本文件:

$.post('indexEdit.php', {info: "info to ad to file"}, function(data){ /*callback here*/ }); 

确保indexEdit.php具有会话验证功能,或者其他人可以尝试向其发布信息并执行外部编辑。

0

要将代码添加到div的开头,请使用prepend方法。要将代码添加到div的末尾,请使用append方法。

以下是用于添加代码的html页面的正文2个例子:

$("body").prepend("This is some div added to the start of the page."); 
$("body").append("This is some div added to the end of the page."); 

如果你想动态加载的内容,你将不得不使用ajax方法和回调使用上面的代码。

相关问题