2012-10-09 121 views
0

此代碼從後面的代碼中獲取來自公共靜態字符串的返回值,並顯示警報中返回的內容。PageMethods實際返回什麼?

<script type="text/javascript"> 
function GetFromServer() 
{ 
PageMethods.GetHello(OnGetHelloComplete); 
} 
function OnGetHelloComplete(result, userContext, methodName) 
{ 
alert("Result: " + result + "\n" + 
"Context: " + userContext + "\n" + 
"Method name: " + methodName); 
} 
</script> 

後面代碼中的web方法是一個公共靜態字符串。但是它返回的是什麼?

我爲什麼不能寫?

var myString = PageMethods.GetHello() 

哪裏是「結果」和「的UserContext」和「方法名」出現?

編輯:請忽略,我看了看源代碼,看到了那裏輸出的內容。

回答

2

GetHello調用服務器的調用,OnGetHelloComplete是一個回調,當請求完成並且參數正在填充時執行。

相關問題