0
$('area').on('mouseover', function() {
var territory = $(this).attr('name');
var territoryString = new String(territory);
var owner = <%game.getTerritory(territoryString).getOwner().getName(); %>;
$('#selection').html(territory);
});
});
我試圖從我存儲爲JSP對象的Game對象中獲取數據。我試圖獲得的領土位於遊戲對象內,作爲領土列表。有沒有辦法通過JavaScript變量作爲參數?或者是否需要使用區域列表創建一個JSP對象?JSP對象內的Javascript變量
沒有,有沒有這樣的,因爲JSP是在處理服務器端和客戶端的JavaScript –
可能重複[參考:爲什麼我的Javascript中的PHP(或其他服務器端)代碼無法正常工作?](http://stackoverflow.com/questions/13840429/reference-why -does-the-php-or-other-server-side-code-in-my-javascript-not-wor) – Quentin
這裏的解決方案是使用一個ajax請求,它可以將所選的「地區」發送到服務器和服務器端返回所有者的值 –