[英]Load a data from a page to another page using jquery ajax
I have two pages, index.php and block1.php I wanted to load a data from block1.php to a div #details in index.php 我有两个页面, index.php和block1.php我想将block1.php中的数据加载到index.php中的div #details
here's my code 这是我的代码
index.php
的index.php
<div id="pop_box">
<div class="close"><span id="close">×</span></div>
<div id="block"></div>
<div id="details"></div>
</div>
block1.php
block1.php
<script>
$(document).ready(function() {
var lnk;
$('[href]').click(function() {
lnk = '';
lnk = $(this).attr('href');
if (lnk.charAt(1) == "b") {
var lot = lnk;
$.ajax({
url: "2dmap_func.php",
method: "POST",
dataType: "text",
data: {
lot: lot
},
success: function(data) {
//alert(data);
$('index.php #pop_box #details').load(data);
}
});
}
});
});
</script>
as you can see I want to load the data from block1.php to index.php's div#details and this code doesn't work. 正如您所看到的,我想将block1.php中的数据加载到index.php的div#详细信息,此代码不起作用。
$('index.php #pop_box #details').load(data);
In you index.php add following line: 在你index.php中添加以下行:
<?php include_once 'block1.php' ?>
In your block1.php change following line: 在你的block1.php中更改以下行:
$('index.php #pop_box #details').load(data);
to 至
$('#details').html(data); // if data is valid html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.