곰시기's

JQuery - change, ajax 본문

Web Development/JavaScript

JQuery - change, ajax

곰시기 2021. 2. 8. 13:29
$( "#test1" ).change(function( e ){ 
  $.ajax({
    type: "post",
    url : "https://",
    data: { mode : "test", sido : $("#test1").val() },
    contentType: 'application/x-www-form-urlencoded; charset=euc-kr',
    dataType:"html",
    success : function( data ) {
      data = JSON.parse( data );
      if( data.code == "002" ) {
        let html = "<option value='0' selected='selected'>test</option>";
        html    += data.content;
        $( "#test" ).empty();
        $( "#test" ).append( html );
        searchFunc();
      } else {
        console.log( data.msg );
      }
    }
  })
});

'Web Development > JavaScript' 카테고리의 다른 글

JQuery - unescapeHtml  (0) 2021.02.12
JQuery - 드래그 체크 박스  (0) 2021.02.11
JQuery - AJAX Method  (0) 2021.02.03
JQuery - 다중 선택자  (0) 2021.02.03
JQuery - form validator  (0) 2017.12.04
Comments