티스토리 뷰

반응형

2013.05.22   

 

var addr_url = "/Share/menuInfoTestAjax.asp?fact=detail&menuPkId="+value;

    var xmlHttp = createXMLHttpRequest();
    xmlHttp.open("GET", addr_url, true);
    xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=euc-kr");
    xmlHttp.setRequestHeader("Pragma", "no-cache");
    xmlHttp.send(null);

    xmlHttp.onreadystatechange = function() {
     if(xmlHttp.readyState == 4 ) {
      if(xmlHttp.status == 200) {
      var json = xmlHttp.responseText;
      var obj = JSON && JSON.parse(json) || $.parseJSON(json);

 //       alert(obj.menupkid); 성공함.
       setInputForm(obj,document.MenuInfoTestForm);
      }
     }

 

방법은 위와 같고

asp에서 했을 때 사용함.

 

JSON.parse 가 IE 9 에서는 에러가 발생되어

json2.js 추가 후

 

var obj = JSON && JSON.parse(json) || $.parseJSON(json);

 

사용하여 적용하였다.

 

반응형