ajax jQuery/JavaScript

var dataForm = {nm: $("#nm").val(), id: id };



$.ajax({

url: baseUrl,

//async : false,

dataType : "json",

type: "POST",

data: dataForm,

success:function(result){

var cnt = result;

if(cnt > 0){

span.text("중복된 값.");

}else{

span.text(" ");

document.form2.submit();

}

},

error:function(e){

}

});


덧글

  • pointer 2015/07/17 11:55 # 답글

    controller 에서 받을 경우

    @RequestMapping(value="url", method=RequestMethod.POST)
    @ResponseBody
    public int methodName(VO Vo) throws Exception{
    int result =service.name(Vo);
    return result;
    }
  • pointer 2015/07/17 11:56 # 답글

    base url


    baseUrl = getUrl();
    function getUrl(){
    pathArray = location.href.split( '/' );
    protocol = pathArray[0];
    host = pathArray[2];
    url = protocol + '//' + host+'/'+pathArray[3];
    return url;
    }
댓글 입력 영역