Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/454.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何将Thymeleaf对象从基本页面传递到ajax生成的页面?_Javascript_Jquery_Spring Boot_Thymeleaf - Fatal编程技术网

Javascript 如何将Thymeleaf对象从基本页面传递到ajax生成的页面?

Javascript 如何将Thymeleaf对象从基本页面传递到ajax生成的页面?,javascript,jquery,spring-boot,thymeleaf,Javascript,Jquery,Spring Boot,Thymeleaf,我有一个注册过程,有子步骤,我有这些子步骤的单独HTML页面,以便于管理。现在我有了一个“基本页面”,即容器。下面的div是我加载子页面的地方 <div id="substeps" th:object="${stepFourForm}"> </div> 加载的子步骤页面如何检索基本页面上的stepFourForm对象?在加载子步骤页面之前,您应该删除div内容。你可以用胸腺细胞碎片来做 $.ajax({ type: "GET", url: "/examp

我有一个注册过程,有子步骤,我有这些子步骤的单独HTML页面,以便于管理。现在我有了一个“基本页面”,即容器。下面的div是我加载子页面的地方

<div id="substeps" th:object="${stepFourForm}">
</div>

加载的子步骤页面如何检索基本页面上的
stepFourForm
对象?

在加载子步骤页面之前,您应该删除
div
内容。你可以用胸腺细胞碎片来做

$.ajax({
    type: "GET",
    url: "/example-url",
    success: function (data) {
        $('#substeps').html('');
        $('#substeps').html(data);

    }
});
控制器代码:

@RequestMapping("/example-url")
public ModelAndView example() {

    ModelAndView view = new ModelAndView("substep1  :: content");
    return view;
}
示例片段html名称子步骤1

<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org"
      xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
      xmlns:dt="http://www.thymeleaf.org/dandelion/datatables">
<head>
    <meta charset="UTF-8"/>
    <title>Title</title>
</head>
<body>

<div th:fragment="content">
    --some content
</div>

</body>
</html>

标题
--一些内容
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org"
      xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
      xmlns:dt="http://www.thymeleaf.org/dandelion/datatables">
<head>
    <meta charset="UTF-8"/>
    <title>Title</title>
</head>
<body>

<div th:fragment="content">
    --some content
</div>

</body>
</html>