public Open ( System.Net.HttpVerb verb, string url ) : void | ||
verb | System.Net.HttpVerb | |
url | string | |
리턴 | void |
public Resource Load(string url) { Resource ret = new Resource(); ret.Finished = false; XmlHttpRequest req = new XmlHttpRequest(); req.Open(HttpVerb.Get, url, true); req.OnReadyStateChange = delegate() { if (req.ReadyState == ReadyState.Loaded && req.Status == 200) { ret.Finished = true; /*parse the xml document*/ ret.Data = this.ParseShader(XmlDocumentParser.Parse(req.ResponseText)); } }; req.Send(); return ret; }
/// <summary> /// Конструктор. /// </summary> static HelloWorldPage() { // Ищем кнопку «helloButton». Element helloButton = Document.GetElementById("helloButton"); // Задаем обработчик события нажатия этой кнопки. helloButton.AddEventListener("click", delegate { // Ищем текстовое поле ввода. InputElement nameTextBox = Document.GetElementById("nameTextBox").As<InputElement>(); // Создаем объект XmlHttpRequest. XmlHttpRequest xhr = new XmlHttpRequest(); // Открываем этот объект XmlHttpRequest, передав ему часть пути // URL в который включили имя посетителя. xhr.Open(HttpVerb.Get, "/Home/World/" + nameTextBox.Value.EncodeUriComponent()); // Задаем обработку события получения результата. xhr.OnReadyStateChange = delegate { // Проверяем состояние загрузки результата запроса. if (xhr.ReadyState == ReadyState.Loaded) { // Десериализуем полученную JSON-строку в объект JavaScript. ServerResult data = (ServerResult) Script.Eval("(" + xhr.ResponseText + ")"); // Формируем строку, отображаемую посетителю. string greeting = String.Format("{0}{1}...", data.Greeting, data.TimeStamp); // Отображаем посетителю приветствие. Script.Alert(greeting); } }; // Выполняем запрос. xhr.Send(); }, false); }
public static XmlHttpRequest Send (this FormData fd, SendFormDataConfig config){ var rq = new XmlHttpRequest (); rq.Open (config.Verb , config.Url); foreach (var h in config.Handlers) rq.AddEventListener (h.Key, h.Value); rq.SendFormData (fd); return rq; }
private void LoadWines() { int skip = _pageIndex.GetValue() * WinesPerPage; XmlHttpRequest xhr = new XmlHttpRequest(); xhr.OnReadyStateChange = delegate() { if ((xhr.ReadyState == ReadyState.Loaded) && (xhr.Status == 200)) { WineResults results = Json.ParseData<WineResults>(xhr.ResponseText); if (results.Count != 0) { _pages.SetValue(Math.Ceil(results.Count / WinesPerPage)); } Wines.SetValue(results.Wines); Wine selectedWine = null; if ((results.Wines != null) && (results.Wines.Length != 0)) { selectedWine = results.Wines[0]; } SelectedWine.SetValue(selectedWine); } }; xhr.Open(HttpVerb.Get, "/wines/?skip=" + skip + "&count=" + WinesPerPage, true); xhr.Send(); }
public static void SaveFileNoApi(object fileContents) { GetDataAsyncOptions gdo = new GetDataAsyncOptions(); gdo.Rows = RowType.ThisRow; gdo.CoercionType = CoercionType.Matrix; FolderHelper.GetRecordFolderID(delegate(string folderID) { request = new XmlHttpRequest(); string URL = string.Format("{0}/{1}/files/{2}?access_token={3}", APIBaseUrl, folderID, CurrentFile.Name, CookieHelper.AccessToken); request.Open("PUT", URL, true); request.OnReadyStateChange = OnReadyChange; request.OnError = OnUploadError; request.OnLoad = OnLoad; request.ResponseType = XmlHttpRequestResponseType.Json; request.Upload.OnProgress = OnUploadProgress; request.Send(fileContents); }); }
private static XmlDocument GetResponse(string soapXmlPacket, string action, Action<object> asyncCallback) { bool isAsync = (asyncCallback != null); string xml = getSoapEnvelope(soapXmlPacket); string msg = null; XmlHttpRequest xmlHttpRequest = new XmlHttpRequest(); xmlHttpRequest.Open("POST", GetServerUrl() + "/XRMServices/2011/Organization.svc/web", isAsync); xmlHttpRequest.SetRequestHeader("SOAPAction", "http://schemas.microsoft.com/xrm/2011/Contracts/Services/IOrganizationService/" + action); xmlHttpRequest.SetRequestHeader("Content-Type", "text/xml; charset=utf-8"); // This is only needed when debugging via localhost - and accessing the CRM webservices cross domain in chrome if (WithCredentials) { Script.Literal("{0}.withCredentials = true;", xmlHttpRequest); } if (isAsync) { xmlHttpRequest.OnReadyStateChange = delegate() { if (xmlHttpRequest == null) return; if (xmlHttpRequest.ReadyState == ReadyState.Loaded) { // Capture the result XmlDocument resultXml = xmlHttpRequest.ResponseXml; string errorMsg = null; if (xmlHttpRequest.Status != 200) { errorMsg = GetSoapFault(resultXml); } // Tidy Up Script.Literal("delete {0}", xmlHttpRequest); xmlHttpRequest = null; if (errorMsg != null) { asyncCallback(errorMsg); } else { // Callback asyncCallback(resultXml); } } }; xmlHttpRequest.Send(xml); return null; } else { xmlHttpRequest.Send(xml); // Capture the result XmlDocument resultXml = xmlHttpRequest.ResponseXml; // Check for errors. if (xmlHttpRequest.Status != 200) { msg = GetSoapFault(resultXml); } // Tidy Up Script.Literal("delete {0};", xmlHttpRequest); xmlHttpRequest = null; if (msg != null) { throw new Exception("CRM SDK Call returned error: '" + msg + "'"); } else { // Return return resultXml; } } }
private void CORS() { xhr = new XmlHttpRequest(); try { xhr.Open(HttpVerb.Get, _url); xhr.OnReadyStateChange = delegate() { if (xhr.ReadyState == ReadyState.Loaded) { LoadData(xhr.ResponseText); } }; xhr.Send(); } catch (Exception err) { _message = err.Message; State = StateType.Error; throw (err); } }
public Resource Load(string url) { Resource ret = new Resource(); ret.Finished = false; XmlHttpRequest req = new XmlHttpRequest(); req.Open(HttpVerb.Get, url, true); req.OnReadyStateChange = delegate () { if(req.ReadyState == ReadyState.Loaded && req.Status == 200) { ret.Finished = true; ret.Data = Json.Parse(req.ResponseText); } }; req.Send(); return ret; }