一尘不染

使用jQuery刷新特定的div

jsp

得到响应后,我想使用ajax调用刷新特定的div标签

<script>
    $(document).ready(function() {

        $('#add-new-department').submit(function(event) {
            var departmentname = $('#departmentname').val();


            $.ajax({
                url : $("#add-new-department").attr("action"),
                type : "POST",
                data : "departmentname="+departmentname,

                success : function(response) {
                    $('#status').html(response);
                    $('#departmentname').val('');
                    $('#department').load("");   
                }
            });

            event.preventDefault();
        });

    });
</script>

我想在jsp页面中更新一条消息

 <div id="department">Department Updated : <% new Date(); %> </div>

我的要求是像ajax调用后 刷新 div标签

 $('#department').refresh();

阅读 1624

收藏
2020-06-08

共1个答案

一尘不染

$.ajax({
  url : $("#add-new-department").attr("action"),
  type : "POST",
  data : "departmentname="+departmentname,

  success : function(response) {
     $('#status').html(response);
     $('#departmentname').val('');
     $('#department').html('Department Updated: ' + new Date());   
  }
});
2020-06-08