웹 프론트엔드정리하자 정리
$.get(url , data, function(data, status,xhr), dataType)
url : 요청을 보낼 url
data : 보낼 데이터...
function : 몰라...
dataType:응답받을 데이터 타입
xml, html, text, script,json, 이 있음
- 요청 url만 있으며 리턴 값 무시
$.get('/popup') ;
- 요청 url , 데이터, 리턴 값 무시
$.get('/popup', {id:'myname', pw:'0000'}) ;
- 요청 url, 리턴 값
$.get('/popup', function(data){ alert(data) ; }) ;
- 요청 url, 리턴 값 , 결과값 형식
$.get('/popup', function(data){ alert(data) ; }, 'text') ;
>> get 이나 post나 문법은 같은 듯
- url + 데이터 + 리턴 후 메시지
-요청 url + 데이터 + 완료 후 리턴 메시지
$.ajax({
type: "post",
url: url1,
}).done(function(data){
alert(data);
});
- 최종 버전 리턴 html 가져오기
$.ajax({
url: url1,
cache:false
}).done(function(data){
$('#result').append(data);
});
- 서버에 데이터 보낸 후 처리, 리턴 메시지 보여주기와 실패시 메시지
var req = $.ajax({
url:'/popup' ,
type:'post',
data: {id:'1111'},
datayType:'html'
});
req.done(function(msg){
$('#show).html(msg);
});
req.fail(function(msg, textStatus){
alert('fail!' + textStatus);
});
- js 로딩 및 실행
$.ajax({
type: "get",
url: 'mask.js',
dataType:'script'
});
'개발 > JQuery' 카테고리의 다른 글
text 박스의 값 전부 초기화 하기 (0) | 2018.02.13 |
---|---|
iframe으로 삽입한 화면에서 부모에 접근하기 (0) | 2018.02.13 |
json으로 받아온 값 select 박스에 add 하기 (0) | 2018.02.13 |
jquery function (0) | 2018.02.13 |
siblings (0) | 2018.02.13 |