Re: [問題] 如何將js的回調函數值取出來呢?
※ 引述《dickstar (To you)》之銘言:
: var score = '9';
: $.get('/temp.text', function(data) {
: score = 2;
: });
: alert(score);
: 答案是9而不是2
: 請問我要如何才能將callback函數放到我的score呢?
: 我的環境是Chrome 9.0 + Jquery 1.4.2
解決了
根據http://www.webdeveloper.com/forum/showthread.php?t=180174
謝謝大家的協助
function getFile(fileName){
oxmlhttp = null;
try{
oxmlhttp = new XMLHttpRequest();
oxmlhttp.overrideMimeType("text/xml");
}
catch(e){
try{
oxmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e){
return null;
}
}
if(!oxmlhttp) return null;
try{
oxmlhttp.open("GET",fileName,false);
oxmlhttp.send(null);
}
catch(e){
return null;
}
return oxmlhttp.responseText;
}
var data = getFile('/temp.txt');
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.116.39.126
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 2 之 3 篇):