这是我在stackoverflow上的第一篇文章,但阅读了很多并学习.
我使用一个jquery函数,使用.load函数加载wordpress主题中的post.
但现在我有一个问题,我自己无法解决.
$(document).ready(function(){
$.ajaxSetup({cache:false});
$("#thumbs a").click(function(){
var post_id = $(this).attr("rel")
$("#your_post_here").slideDown("1200", function () {
$("#your_post_here").html("<img src='http://localhost/wp-content/themes/insp/images/ajax-loader.gif' />");
$("#your_post_here").load("http://<?php echo $_SERVER[HTTP_HOST]; ?>/triqui-ajax/",{id:post_id});
});
return false;
});
$("a.close").live("click", function(){
$("#intro").slideUp(1200);
return false;
});
Run Code Online (Sandbox Code Playgroud)
});
问题是我无法在它加载之前将它下载到slideDown.有人知道什么是错的吗?
除了slideDown效果之外,其他工作正常
编辑:
也许我弄错了,放不能真正让它发挥作用.
我这样说,这是错的吗?
$("#thumbs a").click(function(){
var post_id = $(this).attr("rel")
$("#your_post_here").slideDown("200", function () {
$("#your_post_here").html("<img src='http://localhost/wp-content/themes/insp/images/ajax-loader.gif' />");
$("#your_post_here").load("http://<?php echo $_SERVER[HTTP_HOST]; ?>/triqui-ajax/",{id:post_id});
});
Run Code Online (Sandbox Code Playgroud)
你需要把.load()在.slideDown()的回调.
$("#your_post_here").slideDown("200", function () {
$("#your_post_here").html("<img src='http://localhost/wp-content/themes/insp/images/ajax-loader.gif' />");
$("#your_post_here").load("http://<?php echo $_SERVER[HTTP_HOST]; ?>/triqui-ajax/",{id:post_id});
});
Run Code Online (Sandbox Code Playgroud)
//编辑:
$("#your_post_here").slideDown("200", function () {
$(this).html("<img src='http://localhost/wp-content/themes/insp/images/ajax-loader.gif' />");
$(this).load("http://<?php echo $_SERVER[HTTP_HOST]; ?>/triqui-ajax/",{id:post_id});
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5406 次 |
| 最近记录: |