[jQuery] load with callback confusion
How come this code doesn't work?
$("span#myinfo").mouseover(function(){
$("span#mycontent").load("mytext.txt",function(){
var soffset = $(this).offset();
var stop = soffset.top;
var ihgt = $("div#footer").css("height");
var mtop = $("div#mydiv").css("top");
var mhgt = $("div#mydiv").outerHeight() + 50;
var ntop = stop - mhgt;
$("div#mydiv").css("top",ntop);
$("div#mydiv").fadeIn("slow");
});
});
This version works but, I don't want to display the div element until
the small text file has completed loading.
$("span#myinfo").mouseover(function(){
$("span#mycontent").load("mytext.txt");
var soffset = $(this).offset();
var stop = soffset.top;
var ihgt = $("div#footer").css("height");
var mtop = $("div#mydiv").css("top");
var mhgt = $("div#mydiv").outerHeight() + 50;
var ntop = stop - mhgt;
$("div#mydiv").css("top",ntop);
$("div#mydiv").fadeIn("slow");
});