JAVASCRIPT

jQuery.ajax()를 이용한 페이지 실행

Dayis 2010. 12. 21. 16:04
1. 데이터 직접 입력
$.ajax({
type: "POST",
url: "some.asp",
data: "name=John&location=Boston",
success: function(msg){
if (msg=="Done"){
alert( "Data Saved: " + msg );
}
}
});

참조 URL : http://api.jquery.com/jQuery.ajax/

2. FORM 전송
var string = $("form[name=폼네임]").serialize();
$.ajax({   
type: "POST",  
url: "form_proc.asp",   
data: string,   //&a=xxx 식으로 나옴
success: function(msg){
//메세지에 따른 처리
}
});

※ <textarea>의 엔터를 적용하기 위해서는 Replace 함수를 적용.
data: "content="+document.frmTest.content.value.replace(/\n/g,"<br/>"),