我想从我的控制器中填充一个div,它用 AJAX 为我的onchange调用,但我不能让它工作,我想问题出在我调用的控制器中的函数中。
我尝试使用返回视图,但没有任何效果,我尝试使用setBody,但它不能为表提供循环。
下面是我想填写的div:
<div id="tableCont"></div>
下面是我的myscript.js中的脚本:
function call_user_menu ()
{
$.ajax({
type: 'GET',
url: 'http://localhost:8080/menumanagement/formMenuUser',
dataType: 'html',
success: function (html) {
$("#tableCont").empty();
$("#tableCont").html(html);
},
error: function(){
Swal.fire({
title: 'Menu Data failed to load!',
text: "",
icon: 'warning',
confirmButtonColor: '#d33',
cancelButtonColor: '#d33',
})
},
});
}
下面是我在Controller中的函数:
public function formMenuUser()
{
//the default return view :
return view('menu_form-menu-user.php');
//what should I write here to call the view to fill the div?
//can I use the setBody? but I can't use my foreach there
}
我真的很感激任何可以提供的帮助。谢谢
1条答案
按热度按时间mm5n2pyu1#
你应该像这样穿过风景。
阅读-处理响应