下面是一個例子:如何從JavaScript傳遞服務器端方法的參數值?
的JavaScript:
var b = 'Banana';
var list= <%= getJson() %>; // want to pass b?
C#方法:
using System.Web.Script.Serialization;
....
public string getJson(string x)
{
var list = new List<object>{new []{ "1","Apple"}, new []{ "2",x}};
return (new JavaScriptSerializer()).Serialize(list);
}
如何傳遞變量b當我打電話的getJSON( )來自Jav的 aScript?
Heave你試過ECHO嗎? – durbnpoisn
@durbnpoisn:我怎樣才能回聲呢?你能告訴我代碼片段嗎? –