var webRequest = null; function sendRequest(action) { webRequest = new Sys.Net.WebRequest(); webRequest.set_url("Handlers/Complex.ashx"); webRequest.get_headers()["action"] = action; webRequest.set_body("data=" + encodeURIComponent("Hello World!")); webRequest.set_httpVerb("POST"); webRequest.set_timeout(3000); webRequest.add_completed(onCompleted); webRequest.invoke(); } function onCompleted(response, eventArgs) { if (response.get_aborted()) { alert("Request aborted!"); } else if (response.get_responseAvailable()) { var statusCode = response.get_statusCode(); if ((statusCode < 200) || (statusCode >= 300)) { alert("Error occurred!"); } else { alert(response.get_responseData()); // response.get_xml(); // response.get_object(); // response.getResponseHeader(...); } } else if (response.get_timedOut()) { alert("Request timed out!"); } else { alert("Error occurred!"); } }