如何将JavaScript load_modal();
调用到另一个文档函数?
当load_modal在另一个文档函数内部时,我试图将其load_modal()
称为另一个文档函数
function load_modal(data){
$('#modal').html(data);
}
$(document).on('clicl','.getID', function(){
var id = $(this).attr("id");
var action = "add";
$('#viewtask').modal('show');
$.ajax({
url: "modal_view.php",
method: "POST",
data:{id:id,action:action},
success:function(data){
load_modal(data);
}
});
$(document).on('click','.esubtask',function(){
var id = $(this).attr("id");
var subte = $('#esubtask').val();
var edittask = "a";
if (subte=='') {
toastr.error('Please enter your subtask', '', {timeOut: 4000});
else{
$.ajax({
url: "server.php",
method:"POST",
data:{id:id,subte:subte,edittask:edittask},
success:function(response){
if (response=="success") {
toastr.success('Subtasks Updated Successfully', '', {timeOut: 4000});
$("#btn-remove").remove();
$('.remove').remove();
load_modal();
}else{
toastr.error('Failed to add', '', {timeOut: 4000});
}
}
});
}
});
没有错误,但我想将load_modal
调用到另一个文档功能