[英]Load .php page into a div Ajax and Javascript
(I am pretty new to all this.) I have a page where the user can click between different sorting methods of user posts. (我对这一切都很陌生。)我有一个页面,用户可以在用户帖子的不同排序方法之间点击。 Depending on which they click the content shown will correspond. 根据他们点击的内容,显示的内容将对应。
function newContent()
{
$.ajax({
url: 'ajax/newcontent.php',
success: function()
{
$("#content_div").empty().load("ajax/newcontent.php");
}
});
}
This is what I have now. 这就是我现在拥有的。 But instead of loading the code from the .php page into the #content_box, the #content_box just goes blank. 但是#content_box不是将.php页面中的代码加载到#content_box中,而是空白。
Any help would be awesome! 任何帮助都是极好的!
EDIT ** changed #content_dov to #content_div - whoops 编辑**将#content_dov更改为#content_div - whoops
Why are you using two ajax requests? 你为什么要使用两个ajax请求? You just need to use 你只需要使用
$("#content_dov").load("ajax/newcontent.php");
The full code is 完整的代码是
function newContent()
{
$("#content_dov").load("ajax/newcontent.php");
}
function newContent()
{
$.ajax({
url: 'ajax/newcontent.php',
success: function(data)
{
$("#content_dov").html(data);
}
});
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.