我正在尝试使用此功能将外部文件加载到div
$(document).ready(function(){
$("#postdiv").load('posts.php');
});
一切正常。
问题是,我需要将参数/变量从调用者页面传递到posts.php,并使用它们进行一些过滤。
我怎样才能做到这一点 ?
参考方案
使用ajax
ajax是更好的选择,最佳实践。
var value = "value of the data here";
$.ajax({
url: "posts.php",
data: "key="+value,
type: "post",
success: function(data){
$('#postdiv').html(data);
}
});
jQuery Ajax PHP重定向到另一个页面 - phpJavaScript文件:$.ajax({ type: "POST", url: "ajax.php", data: dataString, success: function(r) { $("#div").html(r); } }); 我想在成功的情况下将页面重定向到new.php,所以在我使用a…
jQuery ajax()返回json对象,但未正确警告 - php为什么无法使用data [0] .id返回ID? $(document).ready(function(){ $.ajax({ type: 'POST', dataType: "json", url: '<?php echo matry::base_to('tests/map_it'…
jQuery AJAX fadeIn内容 - phpThis question already has answers here: Closed 7 years ago. Possible Duplicate: Making my ajax updated div fade in我希望将AJAX调用中的内容发送到页面上的fadeIn,但是当我使用此代码$('#sub_container')…
jQuery Ajax问题 - php在我的post.php中,我使用$ .ajax函数从其他文件加载一些html数据,将其称为form.html。我的问题是当添加到post.php的DOM中时,form.html是否可以访问post.php的POST / GET数据? 参考方案 为什么不使用$ .ajax发布到php文件,该文件返回html数据。这样,您可以在html中填写发布的数据。
jQuery Ajax url指向php函数 - php您好,是否可以使用Ajax从PHP函数检索数据?我希望我的Ajax网址指向我的功能之一。请在下面查看我的代码。像这样: <?php class employee{ public function __construct(){ } public function fName($fName){ echo $fName; } public function …