我有一个函数,我将在其中调用每个ajax调用的9函数。在localhost中没有错误,在我的网站上我发现了这个问题。
第3次功能完成后。其他6人获得500内部服务器错误。所以我试图移动另外6个函数将其置于工作的函数内(例如:getBoardLabelCard(id)还有3个函数 - > getStartDate(id),getDueDate(id),getChecklist(id))并且它正在工作。 多个ajax调用中是否有任何代码模式,或者我应该在一个函数中执行所有ajax?
感谢您提供任何建议。对我来说真的很有帮助。
function ajaxModalCard(id)
{
$("#hiddenCardId").val(id);
getBoardCard(id);
getBoardMember(id);
getBoardLabelCard(id);
getStartDate(id);
getDueDate(id);
getChecklist(id);
getComment(id);
getAttachment(id);
getMoveCard(id);
$("#changeArchive").show();
$("#changeSend").hide();
$("#modal3").openModal();
}
function getBoardCard(id)
{
var id = id;
$.ajax({
type: "POST",
url: "board/getBoardCard",
data: {id:id},
dataType:"json",
success: function (response) {
//alert("response");
$.each(response, function(idx, response){
$("#modalCardTitle").text(response.cardTitle);
$("#modalListTitle").text("in list "+response.listTitle);
$("#txtCardTitle").val(response.cardTitle);
$("#hiddenListId").val(response.cardListId);
$("#textareaDescription").text(response.cardDescription);
$("#modalCardDescription").text(response.cardDescription);
});
},
error: function (xhr, ajaxOptions, thrownError) {
alert(xhr.status);
alert(thrownError);
alert(xhr.responseText);
}
});
}
function getMoveCard(id)
{
var id = id;
var boardId = $("#hiddenBoardId").val();
$.ajax({
type: "POST",
url: "board/getMoveCard",
data: {id:id,boardId:boardId},
dataType:"json",
success: function (response) {
//alert("response");
$("#selectListCard").empty();
var gabung = "";
gabung += "<option value=0 disabled selected>Choose a list</option>";
$("#selectListCard").append(gabung);
$.each(response, function(idx, response){
if(response.listStatus == "1" && response.listArchive == "0")
{
var gabung = "";
gabung += "<option value='"+response.listId+"'>"+response.listTitle+"</option>";
$("#selectListCard").append(gabung);
}
});
},
error: function (xhr, ajaxOptions, thrownError) {
alert(xhr.status);
alert(thrownError);
alert(xhr.responseText);
}
});
}
function getBoardMember(id)
{
var id = id;
var boardId = $("#hiddenBoardId").val();
$.ajax({
type: "POST",
url: "board/getBoardMember",
data: {boardId:boardId},
dataType:"json",
success: function (response) {
$("#assignMembers").empty();
$("#iconMember").empty();
$("#iconMember").append("<h6><b>Members</b></h6>");
$.each(response, function(idx, response){
if(response.memberStatus == "1") //Artinya terdapat didalam board sbg member, jika di kick atau leave tidak akan ditampilkan
{
var checked = getBoardAssignChecked(response.userId);
var name = getNameUser(response.userId);
var gabung = "<p>";
if(checked == "true")
{
gabung += "<input type='checkbox' class='assignMembers' id='"+response.userId+"' checked='checked'/>";
var directory = getDirectoryUser(response.userId);
var gabung2 = '<img src="'+directory+'" style="border-radius:50%;" width="32px" height="32px" alt="Profile" />';
$("#iconMember").append(gabung2);
}
else
{
gabung += "<input type='checkbox' class='assignMembers' id='"+response.userId+"' />";
}
gabung += "<label class='black-text' for='"+response.userId+"' />"+name+"</label>";
gabung += "</p>";
$("#assignMembers").append(gabung);
}
});
},
error: function (xhr, ajaxOptions, thrownError) {
alert(xhr.status);
alert(thrownError);
alert(xhr.responseText);
}
});
}
function getBoardAssignChecked(id)
{
//userId
var userId = id;
var cardId = $("#hiddenCardId").val();
var checked = "false";
$.ajax({
async:false,
type: "POST",
url: "board/getBoardAssignChecked",
data: {userId:userId,cardId:cardId},
success: function (response) {
checked = response;
},
error: function (xhr, ajaxOptions, thrownError) {
alert(xhr.status);
alert(thrownError);
alert(xhr.responseText);
}
});
return checked;
}
function getBoardLabelCard(id)
{
var id = id;
$.ajax({
type: "POST",
url: "board/getLabelCard",
data: {id:id},
dataType:"json",
success: function (response) {
//alert(response);
$("#labelred").prop("checked",false);
$("#labelyellow").prop("checked",false);
$("#labelgreen").prop("checked",false);
$("#labelblue").prop("checked",false);
$("#ajaxLabelCard").empty();
$("#ajaxLabelCard").append("<h6><b>Label</b></h6>");
$.each(response, function(idx, response){
if(response.labelRed == "true")
{
$("#labelred").prop("checked",true);
var label = '<div class="red" style="width:28px;height:28px;border-radius:15%;margin:1px;float:left;"></div>';
$("#ajaxLabelCard").append(label);
}
if(response.labelYellow == "true")
{
$("#labelyellow").prop("checked",true);
var label = '<div class="yellow" style="width:28px;height:28px;border-radius:15%;margin:1px;float:left;"></div>';
$("#ajaxLabelCard").append(label);
}
if(response.labelGreen == "true")
{
$("#labelgreen").prop("checked",true);
var label = '<div class="green" style="width:28px;height:28px;border-radius:15%;margin:1px;float:left;"></div>';
$("#ajaxLabelCard").append(label);
}
if(response.labelBlue == "true")
{
$("#labelblue").prop("checked",true);
var label = '<div class="blue" style="width:28px;height:28px;border-radius:15%;margin:1px;float:left;"></div>';
$("#ajaxLabelCard").append(label);
}
if(response.labelRed == "false" && response.labelYellow == "false" && response.labelGreen == "false" && response.labelBlue == "false")
{
$("#ajaxLabelCard").empty();
}
});
},
error: function (xhr, ajaxOptions, thrownError) {
alert(xhr.status);
alert(thrownError);
alert(xhr.responseText);
}
});
}
function getStartDate(id)
{
var id = id;
$.ajax({
type: "POST",
url: "board/getStartDate",
data: {id:id},
dataType:"json",
success: function (response) {
$("#ajaxStartDate").empty();
if(response != "")
{
}
$.each(response, function(idx, response){
//alert(response.startDate); //2018-03-07 12:00:00
var date = response.startDate;
var pecah = date.split(" ");
var tanggal = pecah[0];
var waktu = pecah[1];
var tanggal2 = tanggal.split("-");
var waktu2 = waktu.split(":");
var tgl = tanggal2[2];
var bln = tanggal2[1];
var jam = waktu2[0];
if(bln == "01")
{
bln = "Jan";
}
else if(bln == "02")
{
bln = "Feb";
}
else if(bln == "03")
{
bln = "Mar";
}
else if(bln == "04")
{
bln = "Apr";
}
else if(bln == "05")
{
bln = "May";
}
else if(bln == "06")
{
bln = "Jun";
}
else if(bln == "07")
{
bln = "Jul";
}
else if(bln == "08")
{
bln = "Aug";
}
else if(bln == "09")
{
bln = "Sep";
}
else if(bln == "10")
{
bln = "Oct";
}
else if(bln == "11")
{
bln = "Nov";
}
else if(bln == "12")
{
bln = "Dec";
}
if(response.startDateStatus == "1")
{
$("#ajaxStartDate").append("<h6><b>Start Date</b></h6>");
var gabung = "<p>";
if(response.startDateChecked == "1")
{
gabung += "<input type='checkbox' id='sd' onchange='changeStartDateChecked(\""+id+"\")' checked='checked'/>";
}
else
{
gabung += "<input type='checkbox' id='sd' onchange='changeStartDateChecked(\""+id+"\")' />";
}
gabung += "<label for='sd'>"+bln+" "+tgl+" at " +jam+":00 - </label><a class='roleActivityStartDate' style='display:none;' href='javascript:void(0);' onclick='deleteStartDate(\""+id+"\")' >Remove</a>";
gabung += "</p>";
}
/*$("#ajaxStartDate").append("<p>");
$("#ajaxStartDate").append("<input type='checkbox' id='a2' />");
$("#ajaxStartDate").append("<label for='a2'>"+bln+" "+tgl+" at " +jam+":00</label>");//Feb 26 at 12:00PM*/
$("#ajaxStartDate").append(gabung);
});
},
error: function (xhr, ajaxOptions, thrownError) {
alert(xhr.status);
alert(thrownError);
alert(xhr.responseText);
}
});
}
function getDueDate(id)
{
var id = id;
$.ajax({
type: "POST",
url: "board/getDueDate",
data: {id:id},
dataType:"json",
success: function (response) {
$("#ajaxDueDate").empty();
if(response != "")
{
}
$.each(response, function(idx, response){
//alert(response.startDate); //2018-03-07 12:00:00
var date = response.dueDate;
var pecah = date.split(" ");
var tanggal = pecah[0];
var waktu = pecah[1];
var tanggal2 = tanggal.split("-");
var waktu2 = waktu.split(":");
var tgl = tanggal2[2];
var bln = tanggal2[1];
var jam = waktu2[0];
if(bln == "01")
{
bln = "Jan";
}
else if(bln == "02")
{
bln = "Feb";
}
else if(bln == "03")
{
bln = "Mar";
}
else if(bln == "04")
{
bln = "Apr";
}
else if(bln == "05")
{
bln = "May";
}
else if(bln == "06")
{
bln = "Jun";
}
else if(bln == "07")
{
bln = "Jul";
}
else if(bln == "08")
{
bln = "Aug";
}
else if(bln == "09")
{
bln = "Sept";
}
else if(bln == "10")
{
bln = "Oct";
}
else if(bln == "11")
{
bln = "Nov";
}
else if(bln == "12")
{
bln = "Dec";
}
if(response.dueDateStatus == "1")
{
$("#ajaxDueDate").append("<h6><b>Due Date</b></h6>");
var gabung = "<p>";
if(response.dueDateChecked == "1")
{
gabung += "<input type='checkbox' id='dd' onchange='changeDueDateChecked(\""+id+"\")' checked='checked'/>";
}
else
{
gabung += "<input type='checkbox' id='dd' onchange='changeDueDateChecked(\""+id+"\")' />";
}
gabung += "<label for='dd'>"+bln+" "+tgl+" at " +jam+":00 - </label><a class='roleActivityDueDate' style='display:none;' href='javascript:void(0);' onclick='deleteDueDate(\""+id+"\")' >Remove</a>";
gabung += "</p>";
}
$("#ajaxDueDate").append(gabung);
});
},
error: function (xhr, ajaxOptions, thrownError) {
alert(xhr.status);
alert(thrownError);
alert(xhr.responseText);
}
});
}
function getChecklist(id)
{
var id = id;
$.ajax({
type: "POST",
url: "board/getChecklist",
data: {id:id},
dataType:"json",
success: function (response) {
$("#ajaxChecklist").empty();
$.each(response, function(idx, response){
if(response.checklistStatus == "1")
{
var atas = '<div id="checklist'+response.checklistId+'">';
var luaratas1 = '<div class="col s12 m6 l10 ">';
var header = '<h6><b>'+response.checklistTitle+'</b></h6>';
var progressbar = '<div class="progress"><div id="pb'+response.checklistId+'" class="determinate" style="width:0%"></div></div>';
//var item ='<p> <input type="checkbox" id="test3" /><label for="test3">Satu</label></p>';
var item ='<div id="checklistItem'+response.checklistId+'"></div>';
var addatas ='<div id="item'+response.checklistId+'">';
var add = '<p><a href="javascript:void(0);" onclick="changeInput(\''+response.checklistId+'\')">Add an item</a></p>';
var addbawah ='</div>';
var luaratas2 = '</div>';
var luarbawah1 = '<div class="col s12 m6 l1 roleActivityChecklist" style="display:none;">';
var tengah = '<a href="javascript:void(0);" onclick="deleteChecklist(\''+response.checklistId+'\')">Delete</a>';
var luarbawah2 = '</div>';
var a = "</div>";
var gabung = atas+luaratas1+header+progressbar+item+addatas+add+addbawah+luaratas2+luarbawah1+tengah+luarbawah2+a;
$("#ajaxChecklist").append(gabung);
//alert(response.checklistId);
$.ajax({
type: "POST",
url: "board/getChecklistItem",
data: {id:response.checklistId},
dataType:"json",
success: function (response) {
$.each(response, function(idx, response){
if(response.itemStatus == "1")
{
if(response.itemChecked == "1")
{
$("#checklistItem"+response.checklistId).append('<p id="item'+response.itemId+'"> <input type="checkbox" checked="checked" class="cb'+response.checklistId+'" id="test'+response.itemId+'" onchange="changeItem(\''+response.itemId+'\')" onclick="countPb(\''+response.checklistId+'\')" /><label class="black-text" for="test'+response.itemId+'">'+response.itemTitle+'</label><span style="margin-left:7%;" class="ultra-small"><a href="javascript:void(0);" onclick="deleteChecklistItem(\''+response.itemId+'\')" class="right-align red-text">Delete</a></span></p>');
}
else
{
$("#checklistItem"+response.checklistId).append('<p id="item'+response.itemId+'"> <input type="checkbox" class="cb'+response.checklistId+'" id="test'+response.itemId+'" onchange="changeItem(\''+response.itemId+'\')" onclick="countPb(\''+response.checklistId+'\')" /><label class="black-text" for="test'+response.itemId+'">'+response.itemTitle+'</label><span style="margin-left:7%;display:none;" class="ultra-small roleActivityChecklist"><a href="javascript:void(0);" onclick="deleteChecklistItem(\''+response.itemId+'\')" class="right-align red-text">Delete</a></span></p>');
}
countPb(response.checklistId);
}
});
},
error: function (xhr, ajaxOptions, thrownError) {
alert(xhr.status);
alert(thrownError);
alert(xhr.responseText);
}
});
}
});
},
error: function (xhr, ajaxOptions, thrownError) {
alert(xhr.status);
alert(thrownError);
alert(xhr.responseText);
}
});
}
function getDirectoryUser(id)
{
//userId
var id = id;
var directory = "";
$.ajax({
async: false,
type: "POST",
url: "board/getDirectoryUser",
data: {id:id},
success: function (response) {
directory = response;
},
error: function (xhr, ajaxOptions, thrownError) {
alert(xhr.status);
alert(thrownError);
alert(xhr.responseText);
}
});
return directory;
}
function getNameUser(id)
{
var id = id;
var name = "";
$.ajax({
async: false,
type: "POST",
url: "board/getNameUser",
data: {id:id},
success: function (response) {
name = response;
},
error: function (xhr, ajaxOptions, thrownError) {
alert(xhr.status);
alert(thrownError);
alert(xhr.responseText);
}
});
return name;
}
function getLabelCard(id)
{
var id = id;
var label = "";
$.ajax({
async: false,
type: "POST",
url: "board/getLabelCard",
data: {id:id},
dataType:"json",
success: function (response) {
label = response;
},
error: function (xhr, ajaxOptions, thrownError) {
alert(xhr.status);
alert(thrownError);
alert(xhr.responseText);
}
});
return label;
}
function getComment(id)
{
var id = id;
$.ajax({
type: "POST",
url: "board/getComment",
data: {id:id},
dataType:"json",
success: function (response) {
//alert(response);
$("#ajaxComment").empty();
$.each(response, function(idx, response){
if(response.commentStatus == "1")
{
var directory = getDirectoryUser(response.userId);
var name = getNameUser(response.userId);
var gabung = "";
gabung += '<div class="row" id="comment'+response.commentId+'">';
gabung += '<div class="col s12 m4 l1">';
gabung += '<img src="'+directory+'" style="border-radius:50%;" width="32px" height="32px" alt="Profile" />';
gabung += '</div>';
gabung += '<div class="col s12 m4 l11">';
gabung += '<p style="margin-top:-3px;">';
gabung += '<b><u>'+name+'</u></b>';
gabung += '</p>';
gabung += '<p style="margin-top:-13px;" id="textComment'+response.commentId+'">'+response.commentText+'</p>';
gabung += '<div id="changeComment'+response.commentId+'" style="margin-top:-25px;margin-bottom:15px;display:none;">';
gabung += '<textarea id="textareaChangeComment'+response.commentId+'" class="materialize-textarea" >'+response.commentText+'</textarea>';
gabung += '<a class="btn waves-effect waves-light green" style="margin-right:10px;" onclick="changeCommentText(\''+response.commentId+'\')">Change</a>';
gabung += '<a class="btn-floating waves-effect waves-light" onclick="closeEditComment(\''+response.commentId+'\')"><i class="mdi-content-clear"></i></a>';
gabung += '</div>';
gabung += '<p class="ultra-small grey-text darken-4" style="margin-top:-10px;">';
gabung += 'yesterday at 8:17 PM - <a href="javascript:void(0);" onclick="changeReply(\''+response.commentId+'\')"><u>Reply</u></a> - <a href="javascript:void(0);" onclick="editComment(\''+response.commentId+'\')"><u>Edit</u></a> - <a href="javascript:void(0)" onclick="deleteComment(\''+response.commentId+'\')"><u>Delete</u></a>' ;
gabung += '</p>';
gabung += '<div id="ajaxReplyComment'+response.commentId+'">';
gabung += '<div class="col s12 m6 l12" id="changeReply'+response.commentId+'">';
gabung += '</div>';
gabung += '</div>';
gabung += '</div>';
gabung += '</div>';
$("#ajaxComment").append(gabung);
$.ajax({
type: "POST",
url: "board/getReplyComment",
data: {commentId:response.commentId},
dataType:"json",
success: function (response) {
//alert(response);
$("#ajaxReplyComment"+response.commentId).empty();
$.each(response, function(idx, response){
if(response.replyStatus == "1")
{
var name2 = getNameUser(response.userId);
var directory2 = getDirectoryUser(response.userId);
var gabung2 = "";
gabung2 += '<div id="replyUser'+response.replyId+'">';
gabung2 += '<div class="col s12 m4 l1">';
gabung2 += '<img src="'+directory+'" style="border-radius:50%;" width="32px" height="32px" alt="Profile" />';
gabung2 += '</div>';
gabung2 += '<div class="col s12 m4 l11">';
gabung2 += '<p style="margin-top:-3px;">';
gabung2 += '<b><u>'+name+'</u></b>';
gabung2 += '</p>';
gabung2 += '<p id="textReply'+response.replyId+'" style="margin-top:-13px;">'+response.replyText+'</p>';
gabung2 += '<div id="changeReply'+response.replyId+'" style="margin-top:-25px;margin-bottom:15px;display:none;">';
gabung2 += '<textarea id="textareaChangeReply'+response.replyId+'" class="materialize-textarea" >'+response.replyText+'</textarea>';
gabung2 += '<a class="btn waves-effect waves-light green" style="margin-right:10px;" onclick="changeReplyText(\''+response.replyId+'\')">Change</a>';
gabung2 += '<a class="btn-floating waves-effect waves-light" onclick="closeEditReply(\''+response.replyId+'\')"><i class="mdi-content-clear"></i></a>';
gabung2 += '</div>';
gabung2 += '<p class="ultra-small grey-text darken-4" style="margin-top:-10px;">';
gabung2 += 'yesterday at 8:17 PM - <a href="javascript:void(0);" onclick="editReply(\''+response.replyId+'\')"><u>Edit</u></a> - <a href="javascript:void(0);" onclick="deleteReply(\''+response.replyId+'\')"><u>Delete</u></a>' ;
gabung2 += '</p>';
gabung2 += '</div>';
gabung2 += '</div>';
$("#ajaxReplyComment"+response.commentId).append(gabung2);
}
});
},
error: function (xhr, ajaxOptions, thrownError) {
alert(xhr.status);
alert(thrownError);
alert(xhr.responseText);
}
});
}
});
},
error: function (xhr, ajaxOptions, thrownError) {
alert(xhr.status);
alert(thrownError);
alert(xhr.responseText);
}
});
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>