我有个问题。有人能解释一下吗?我怎样才能包含另一个.latte文件并发送动态数据呢?
我正在创建api函数,您应该能够通过编写公司名称来获取公司的信息。当我单击搜索时,我可以在控制台中看到我的请求正在通过并发送回响应,并带有正确的数据,但是它不会刷新已经加载的数据。
我的代码的一些示例:
Javascript:
btn.onclick = function() {
modal.style.display = "block";
var firma = $("#firmaName").val();
console.log( "var is " + firma );
$.ajax('data', {
data: { 'firma' : firma}
});
}.latte
<!-- The Modal -->
<div id="myModal" class="modal">
<!-- Modal content -->
<div class="modal-content">
<span class="close">×</span>
{include 'data.latte'}
</div>
</div>发布于 2022-06-11 00:37:32
解决这个问题的最好方法是使用代码片段和$.netteAjax()。
viz:https://doc.nette.org/en/application/ajax
此外,包含标记可以接受参数,然后在加载的模板中使用这些参数,如以下所示:https://latte.nette.org/cs/tags#toc-include
我也会参考,在使用包含的一个她拿铁文件,我会创建组件为您的模式,即。https://doc.nette.org/en/application/components
https://stackoverflow.com/questions/69010647
复制相似问题