我有下面的一段JavaScript代码:在全局变量无法储值JS
var ws_path = "x";
$.get('ws.config', function(data) {
ws_path = data;
alert(ws_path); //alert 1
},
'text');
alert(ws_path); // alert 2
// output = alert 1 = value of data
// alert 2 = x
我有一个困惑”为什么它的行为就像这样?