[英]How to append content from a php file into a div with jquery mobile
[英]How do i load content from a seperate .php/html file into a div with jQuery .append and window.location?
我剛剛使用一些jQuery完成了我的第一個網站,現在我試圖弄清楚如何使用jquery將內容添加到.content div中。 我正在嘗試使用此代碼,但顯然不正確。 基本上,我認為最好是使用單獨的文件,其中包含內容,然后使用jQuery將“ .append()”加載到div中。 我該怎么做呢? 我現在正在使用此代碼:
<div class="content"></div>
$('#about').click(function() {
$('.module1').show(600);
$('.content').animate({'width':'620'},600);
$('.content').append(
window.location.href("about.php")
);
您可以使用.post()
從php加載內容
$('#about').click(function () {
$('.module1').show(600);
$('.content').animate({
'width': '620'
}, 600);
$.post('about.php', function (data) {
$('.content').append(data);
})
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.