AJAX响应后如何通过jQuery设置表单

时间:2019-03-25 12:27:36

标签: jquery spring-mvc

在尝试对控制器进行AJAX调用后,我试图将Spring表单更改为新表单,从而为我提供了要映射到该表单的对象。

表单声明:

<form method="POST" action="/addInput" id="registerForm" >

AJAX呼叫:

$.ajax({
  url : '${findNewFormz}',
  type : 'GET',
  data: {'data': id},
  success : function(data) {
    $('#registerForm').html(data);
  },
  fail: function () {
    console.log("Encountered an error")
  }
});

这里是重点:$('#registerForm')。html(data); 它无法正常工作,将视图全部设置为空白。是否有任何命令或方法来更新表单及其中的所有值?

我的控制器:

@GetMapping("/formIDz")
public @ResponseBody HistoricBO getNewFormz(String data, @ModelAttribute("historic") HistoricBO historic) {
    return historic;
}

谢谢

0 个答案:

没有答案