我有一個JavaScript函數,用於在aspx頁面中的HTML按鈕單擊事件和在頁面代碼隱藏中的服務器方法。當用戶點擊HTML按鈕時,它將被處理,並且按鈕將顯示一個答案。更新按鈕標籤
如何獲得更新的按鈕標籤,因爲它使用的是AJAX?
當我嘗試在某處設置更新時,頁面不會更新按鈕。文本框更新正常工作。從下面的代碼可以看出,btnDivide
目前具有「獲取天氣」的設置值,但我需要在用戶完成處理後更改它。
<script type="text/javascript">
<![CDATA[
// This function creates an asynchronous call to the service
function makeCall(operation){
var n1 = document.getElementById("num1").value;
var n2 = document.getElementById("num2").value;
// If user filled out these fields, call the service
if(n1 && n2){
// Instantiate a service proxy
var proxy = new Service();
// Call correct operation on vf cproxy
switch(operation){
case "gridOne":
proxy.Calculate(AjaxService.Operation.getWeather,n1,n2,
onSuccess, onFail, null);
btnDivide.value = "TestNewValue";
break;
case "gridTwo":
*******
</script>
<style type="text/css">
#result
{
width: 1010px;
}
</style>
</head>
<body>
<h1>Ajax TicTacToe</h1>
<p>Major City: <input type="text" id="num1" onclick="return
num1_onclick()" /></p>
<p>Country: <input type="text" id="num2" onclick="return num2_onclick()"
/></p>
<br />
<input id="btnDivide" type="button" onclick="return makeCall('gridOne');"
value="Get Weather" />