1
由于某种原因,get函数中的newdata在尝试在函数外部使用时丢失了。该警报显示0,但是当我将警报放在get函数中时,它显示80(它应该是什么)。任何想法?失去jquery以外的变量获取
var newdata = 0;
//Get latest stat from file
$.get("http://localhost/?stat=size", function(data) {
//Strip any letters from result (if any)
newdata = data.replace(/\D/g,'');
//alert("Load was performed."+newdata);
});
alert("Load was performed."+newdata);
感谢
,看一下http://stackoverflow.com/questions/14220321/how-to-return-the-response-from-an-ajax-call –
http://stackoverflow.com/questions/ 14220321 /如何返回答案从一个AJAX调用 –