﻿<!--
////////////////////////////////////////////////////////////////////////////////////////////
//	버전	: Ver 1.0.0605101519
//	작성자	: 개발팀 이효준
//	작성일	: 2006.05.10
//	설명	: Microsoft.XMLHTTP를 이용한 웹스크래핑
////////////////////////////////////////////////////////////////////////////////////////////
/*
사용예제) 해당상품코드가 존재하는지를 검사함.
<script language="javascript">
    try
    {
        hr = new HttpRequest();
	    hr.method = "POST";
	    hr.url = "/Ajax/Goods_Exists.aspx";
	    hr.isSync = false;
	    hr.parameters = "PCode=S01-001";
	    alert(hr.response());
    }
    catch(e)
    {
        alert(e);
    }
	   
</script>    
*/
function Create_Http()
{
    if (window.ActiveXObject) 
    {
        try
        {
            return new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch(e)
        {
            try
            {
	            return new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch(e1)
            {
                return null; 
            }
        }
    } 
    else if(window.XMLHttpRequest) 
    {
        return new XMLHttpRequest();
    }
    else
    {
        return null;
    }
}
function HttpRequest()
{
	//기본정보
	this.version = "1.0.0605101519";
	this.name = "HttpRequest";
	this.resultText = "default";

	//셋팅해야할 값
	this.url	= "";
	this.method = "GET"; //default value
	this.parameters = "";
	this.isSync = false;
	this.response = function()
	{
		try
		{
			this.method = this.method.toUpperCase();
			if(this.url == "")
			{
				this.resultText = "error:url";
				return "error:url";
			}
			//define cursor type
			document.body.style.cursor = "wait";
						
			//create object
			var oXMLHTTP = Create_Http();
			
			//Send
			if(this.method == "POST")
			{
			    oXMLHTTP.open(this.method, this.url, this.isSync);
				oXMLHTTP.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
				oXMLHTTP.send(this.parameters);
			}
			else
			{
			    oXMLHTTP.open(this.method, this.url + "?" + this.parameters, this.isSync);
			    oXMLHTTP.send();    
			}
			
			//receive data
			this.resultText = oXMLHTTP.responseText;
			
			//define cursor type
			document.body.style.cursor = "auto";
			
			//return result
			return this.resultText;
		}
		catch(e)
		{
			document.body.style.cursor = "auto";
			return "error:object"
		}
	}
}
-->