Re: [問題] 如何將js的回調函數值取出來呢?

看板Web_Design作者 (To you)時間15年前 (2011/02/25 17:20), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串2/3 (看更多)
※ 引述《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
文章代碼(AID): #1DPtHkKD (Web_Design)
文章代碼(AID): #1DPtHkKD (Web_Design)