我是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;
}
PHP代码
<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必须在那里打印下拉列表)提前感谢
桃花长相依
相关分类