public static void UpdateButton_Click(Event e) { var request = new XMLHttpRequest(); Action<Event> onLoad = delegate { var val = JSON.Parse(request.ResponseText).As<string>(); var dateTime = DateTime.Parse(val); Document.GetElementById<InputElement>("dateTimeInput").Value = dateTime.ToString("yyyy-MM-dd hh:mm:ss"); }; request.OnLoad = onLoad; request.Open("GET", Config.GET_SERVER_TIME_URL + "?" + DateTime.Now.GetTime(), true); request.Send(); }
static string HttpGet(string theUrl) { var xmlHttp = new XMLHttpRequest(); xmlHttp.Open("GET", theUrl, false); // false for synchronous request xmlHttp.ToDynamic().send(null); return xmlHttp.ResponseText; }