here's the part of my code that is giving me the problem:
var sellwinhtml; // global variable
function test(){
var testurl="https://rawgithub.com/kwagjj/mrmine-macro/master/initializing/sell_window_ver2.html";
$.get(testurl,function(data,status){
sellwinhtml=data;
alert(sellwinhtml);
}); //phase1
var win=window.open("","name","width=300,height=300");
win.document.write(sellwinhtml); //phase2
}
theoretically, the code should
1) pop up and give me an alert with showing the contents of variable 'sellwinhtml'
2) open a blank window and then fill it with the html code contained in 'sellwinhtml' thereby showing a new window with something on it, eventually.
but if I run this thing the process happens the other way around.
1) a new window pops up with "undefined" written on it
2) then about a second later, the alert pop up appears showing the correct contents of 'sellwinhtml'.
This is why I thought that the problem is that the 'phase2' part was executed before 'phase1' part was finished.
Is there a way to command 'phase2' to execute when 'phase1' is absolutely finished??