我是这里的 AJAX 新手。ajax的动作执行后如何替换初始的php函数?我发现执行操作后页面不会刷新。这是代码:
javascript
function set_ddm(another_data) {
var result = $.ajax({
url: '../display/ea_form_header.php',
type: 'POST',
data: {
action: 'set_ddm',
Data_store: another_data,
},
success: function(data) {
console.log(data);
}
}).responseText;
}
代码
<td>
<?php
//initial function (customized drop down)
print ddm_jsfunc_employee("employee_list",$employee_list)
set_ddm(data);
if($_POST['action'] =='set_ddm') {
$employee_list=$_POST['Data_store'];
$employee_list_decoded = json_decode($employee_list,true);
//expected this function to replace the initial function after ajax was called
print ddm_jsfunc_employee("employee_list",$employee_list_decoded);
} ?>
</td>
我希望该函数将替换初始函数并显示在主页面中,但它仅在 ajax 之后显示在控制台中(页面不会刷新以显示它)。代码或任何解决方案有什么问题吗?(ddm_jsfunc_employee 必须在那里打印下拉菜单)提前致谢
30秒到达战场