Pass Success variable to code
Posted
by
João Dias
on Stack Overflow
See other posts from Stack Overflow
or by João Dias
Published on 2012-10-01T15:36:13Z
Indexed on
2012/10/01
15:37 UTC
Read the original article
Hit count: 189
jQuery
|jquery-ajax
How can I pass a variable that has been calculated in the success callback of an ajax function, to the document.ready ?
I have this code
function loadActions()
{
var countDiv;
$.ajax({
type: "POST",
cache: false,
url:"modules/actions/actions.php",
success : function (data) {
$("#actions-container").html(data);
$('.action-details').hide();
countDiv = $('.action-tab-odd').length + $('.action-tab-even').length ;
}
});
return countDiv;
}
$(document).ready(function(){
var count = loadActions();
});
But count is allways undefined. How can I get this to work?
Thank you
© Stack Overflow or respective owner