我不明白为什么call_script_id显示为字符串而不是变量中存储的内容。其他变量工作正常,但从字面上看,call_script_id设置id =“ call_script_id”,而call_reason_id设置正确的数字。
$.ajax({
url: "../selections/call-reasons.php",
type: 'post',
data: {company_uid:"<?php echo $row['company_uid']; ?>"},
dataType: 'json',
success:function(response){
var len = response.length;
$("#call_reasons").empty();
for( var i = 0; i<len; i++){
var call_script_id = response[i]['call_script_id'];
var call_reason_id = response[i]['call_reason_id'];
var call_type = response[i]['call_type'];
var active = response[i]['active'];
$("#call_reasons").append("<tr><td href='../modals/call-types.php' class='call_reason_row' id=" + call_script_id + ">" + call_reason_id + "</td><td id=" + call_script_id + "></td><td id=" + call_script_id + "></td><td><i class='far fa-edit'></i><i class='far fa-calendar-alt'></i><i class='far fa-trash-alt call_reason_trash' id=" + call_reason_id + "></i></td></tr>");
}
// Brings up the pop up to edit call reasons/types
$(".call_reason_row").click(function() {
$('#main-content',parent.document).load($(this).attr('href'), {call_reason_id: this.id, company_uid: "<?php echo $row["company_uid"];?>", active: active});
});
},
error: function (xhr, status, error) {
alert(xhr.responseText);
}
});
$sql = "SELECT cs.id, cs.call_reason, sct.call_type FROM call_script AS cs INNER JOIN selection_call_types AS sct ON cs.call_reason = sct.id WHERE cs.company_uid = '$company_uid'";
$result = mysqli_query($conn, $sql);
$my_array = array();
while($row = mysqli_fetch_array($result) ){
$call_script_id = $row['id'];
$call_reason_id = $row['call_reason'];
$call_type = $row['call_type'];
$active = $row['active'];
$my_array[] = array("call_script_id" => call_script_id, "call_reason_id" => $call_reason_id, "call_type_id" => $call_type, "active" => $active);
}
答案 0 :(得分:0)
我猜我希望问题出在ajax中,因为我不太熟悉该语言。相反,这是因为我在最后一行的$ my_array中缺少变量call_reason_id上的美元符号。