如何在ajax中调用函数吗,如何使函数在ajax调用中调用函数?

$('.projects').hover(function(){

$defBox.stop(true, true).fadeToggle(1000).html('test');

});

成一个函数,然后调用它在一个Ajax调用?

// Check to ensure that a link with href == hash is on the page

if ($('a[href="' + hash + '"]').length) {

// Load the page.

var toLoad = hash + '.php #main-content';

$('#main-content').load(toLoad);

}

$('nav ul li a').click(function() {

var goingTo = $(this).attr('href');

goingTo = goingTo.substring(goingTo.lastIndexOf('/') + 1);

if (window.location.hash.substring(1) === goingTo) return false;

var toLoad = $(this).attr('href') + ' #main-content',

$content = $('#main-content'),

$loadimg = $('#load');

$content.fadeOut('fast', loadContent);

$loadimg.remove();

$content.append('');

$loadimg.fadeIn('slow');

window.location.hash = goingTo;

function loadContent() {

$content.load(toLoad, '', showNewContent)

}

function showNewContent() {

$content.fadeIn('fast', hideLoader, log);

}

function hideLoader() {

$loadimg.fadeOut('fast');

}

return false;

});

我的功能

$('.projects dl').find('dd').hide();

function fadeBox(){

$('#def-box').stop(true, true)

.fadeToggle(1000)

.html('test');

}

$('.projects').hover(function(){

fadeBox();

});

function descBox(){

$('.projects dl').find('dd').hide();

var $data = $(this)

.next('dd')

.html();

$('#def-box').html($data);

}

$('.projects dl dt').hover(function(){

descBox();

});

和Ajax

function showNewContent() {

fadeBox();

descBox();

$content.fadeIn('fast',hideLoader);

}

而且这是行不通的。它假设当dt被徘徊时,其隐藏的dd元素位于它在#def-box中的位置。

function descBox(){

$('.projects dl').find('dd').hide();

var $data = $(this)

.next('dd')

.html('test');

$('#def-box').html($data);

}

另外,dd元素,如果我点击anotherpage隐藏,但在负荷... http://example.co/#home的dd不是隐藏不动了。

2011-02-12

nowayyy

+0

使它成为一个函数很容易,用函数(){`和`}`包围它。但现在确定我明白你的意思,用AJAX调用它 - 在AJAX返回时运行它吗? –

2011-02-12 18:31:53

+0

是的,这是我的意思 –

2011-02-12 18:53:33

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值