달력

42025  이전 다음

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30


같은 id을 갖는 object들을 배열로 가져오려면.. getElementsByName()를 사용하면 된다. 

아래예는 버튼들인데.. 각 상황에 맞게 enable / disable처리 및 className을 변경한다. 

    var buttons = document.getElementsByName('btnCountSMS');

    for( i=0; i < buttons.length; i++ )
    {
       buttons[i].disabled = false;
       buttons[i].name = "UNCOUNT_BTN";
       buttons[i].className = "clsButton";
    }

'FrontEnd > JavaScript' 카테고리의 다른 글

javascript에서 array 복사  (0) 2013.12.13
window, frames, window.top 이해하기..  (0) 2013.11.20
JSON 데이타 다루기..  (0) 2013.11.20
AJAX Call 기본 형태..  (0) 2013.11.20
Javascript study..  (0) 2013.11.12
Posted by 행복한삶~!!
|

JSON 데이타를 Object로 변환하기.. 

데이타 교환을 위해서 사용되는것이 json이다. 

서버로 부터 반환된 결과는 rtn.responseText와 같이 String으로 전달된다. 

전달된 데이타가 json format이라면 rtn.responseText 출력시에 { id:'Outsider', sex:'male' } 형태의 string이 출력된다. 

이를 JS에서 다루기 쉬운 object로 변환하기 위해서는 그냥 eval( rtn.responseText ) 만 하면 된다.


기본 개념잡기 및 보다 상세한 설명은 아래에서.. 

http://opentutorials.org/course/49/3473

http://blog.outsider.ne.kr/257



'FrontEnd > JavaScript' 카테고리의 다른 글

window, frames, window.top 이해하기..  (0) 2013.11.20
같은 이름을 갖는...element들을 배열로 얻어와서 다루기..  (0) 2013.11.20
AJAX Call 기본 형태..  (0) 2013.11.20
Javascript study..  (0) 2013.11.12
object 선언  (0) 2013.10.31
Posted by 행복한삶~!!
|

순수.. XMLHttpRequest 객체를 사용하여 ajax call 할때.. 

jQuery 나 prototype 사용하면.. 인터페이스가 다르다.. 

하지만... 그 내부를 까보면.. 아래와 같은 코드가 있다는거.. 

function ajaxUpdateServerVariable() 
{
	var xmlhttp;
	if (window.XMLHttpRequest)
	{// code for IE7+, Firefox, Chrome, Opera, Safari
	  xmlhttp=new XMLHttpRequest();
	}
	else
	{// code for IE6, IE5
	  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	
	// success 일때 호출되는 call back
	xmlhttp.onreadystatechange=function()
	{	  
	  if (xmlhttp.readyState==4 && xmlhttp.status==200)
	  {
	    //update success	
	    //alert( xmlhttp.responseText );     
	  }
	}
	
	xmlhttp.open("GET","target_url.jsp?param=xxxx",true);
	xmlhttp.send();
}


'FrontEnd > JavaScript' 카테고리의 다른 글

window, frames, window.top 이해하기..  (0) 2013.11.20
같은 이름을 갖는...element들을 배열로 얻어와서 다루기..  (0) 2013.11.20
JSON 데이타 다루기..  (0) 2013.11.20
Javascript study..  (0) 2013.11.12
object 선언  (0) 2013.10.31
Posted by 행복한삶~!!
|