201405

[jq] 메서드 - ajax

오디오양 2014. 5. 8. 09:20

1. 기본

$.ajax({

url: '/test/test.asp',

data: {'userid' : userid, 'userpw' : userpw},

type: 'post', // 전송 방식 : 'get', 'post'

dataType: 'html', // 받을 형식 : 'xml', 'html', 'script', 'json', 'jsonp', 'text'

timeout: 5000,

error: function(xhr, ajaxOptions, thrownError){

alert('error number' + xhr.status + ' ' + xhr.responseText);

return;

},

success: function(html){

alert(html);

}

});



2. serialize

var params = $("form[name=frm]").serialize();


$.ajax({

...

data : params,

...

});



3. 한글깨짐

utf-8, escape 해야 하던가..?



4. css

반환되는 html의 css는 적용이 안되던걸로 기억...