1

I've got two functions and one problem.

hideTable(); ajaxCall(params); 

The function hideTable

function hideTable() { if (effects) { $('#jquerytable tbody').fadeOut(speed); } } 

I want the ajaxCall function to be executed after the hideTable function (which takes a little time). The showTable function should be executed after the ajax call. I tried a lot but nothing worked fine for me. The Ajax call starts before the hideTable function is finished. I think I could use the jQuery queue but I don't know how to apply it to this problem.

By the way, I don't want to use a callback function beacause I want to reuse the hideTable function in other contexts.

Would be nice if you could help me out.

0

2 Answers 2

1

jQuery's animate and hide functions have callbacks you can use.

animate( params, [duration], [easing], [callback] ) hide( speed, callback ) 

So what is the code for hideTable? Does it use $().hide() ? If so, set the callback to be your ajax function

Sign up to request clarification or add additional context in comments.

3 Comments

Thats a good answer. However, is there another without a callback?
That's by far the easiest solution. If you want to reuse the hidetable function, just pass in the callback as a parameter.
There are many other (less desirable) was to solve the problem. You could have a global variable keep track of the state of the table (hidden, animating, shown). Of course, you'd be using the callback to update the global from animating to hidden.
0

@nosredna answer to use callbacks is the way to go but if you want do do it with jquery queue i suggest you to look at this answer to a similar question

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.