コード例 #1
0
        /// <summary>
        /// Gets the response text as an object.
        /// </summary>
        /// <param name="response">The response object.</param>
        /// <returns>The resulting object.</returns>
        public static object GetResponseObject(this XMLHttpRequest response)
        {
            var type = response.getResponseHeader("Content-Type");

            if (type.indexOf("application/json") != -1)
            {
                var json = (dynamic)window.self["JSON"];
                if (json && json.parse)
                {
                    return(json.parse(response.responseText));
                }

                return(window.eval(response.responseText));
            }

            return(response.responseText);
        }