我有两个页面gallery.php和post-result.php ..我得到我的ajax响应在div(模态内容)这是在gallery.php在同一页我想将div值存储在一个php变量中。在同一页上调用ajax响应
<div class="modal-content"> </div>
我的Ajax代码是:
jQuery(document).ready(function(){
jQuery(".varr").click(function(){
var dataId = jQuery(this).attr('data-id');
jQuery.ajax({url:"post-result.php?dataId="+dataId,cache:false,
success:function(result){
jQuery(".modal-content").html(result);}
});
}); });
为什么你在回答后改变问题?你的问题的解决方案是你只需要将'jQuery(“.modal-content”).html(result);'改为'jQuery(“#modal-content”).html(result);' – Bhavin
对不起.....这只是我的打字错误.....我写了ID而不是类 – varsha
和我的问题是,如何通过使用ID而不是类的PHP变量 – varsha