php - Ajax for dependent dropdown is not working in online server
问题描述
I have some issues in my ajax function, the dependent dropdown here i have attached my UI design is working good in localhost but once make it online it doesn't support.Can someone help me to solve this issue
Ajax code:
<script>
function getClo(val) {
var Sid = document.getElementById("usrID").value;
var Auser_nm = document.getElementById("usrNM").value;
document.getElementById("AuserID").value = Sid;
document.getElementById("AuserNM").value = Auser_nm;
$.ajax({
type: "POST",
url: "get_col.php",
data: "courseid=" + val + "&staff_id=" + Sid,
success: function(data){
$("#clo_list").html(data);
}
});
}
</script>
dependent dropdown code:
<select name="coursecode-list" id="coursecode-list" class="course" onchange="getClo(this.value);">
<option value="">Select Course</option>
<?php
$sql = mysqli_query($connection,"SELECT * FROM course");
while ($row=mysqli_fetch_array($sql))
{ ?>
<option value="<?php echo $row['coursecode'];?>">
<?php echo $row['coursecode']." ".$row['coursename']; ?>
</option>
<?php
}
?>
</select>
<select id="clo_list" name="clo_list" class="course" >
<option value="">Select CLO</option>
</select>
get.col.php file code:
<?php
require_once ("database.php");
$query ="SELECT * FROM clo WHERE coursecode = '" . $_POST["courseid"] . "' and
staff_id = '" . $_POST["staff_id"] . "'";
$results = $dbhandle->query($query);
?>
<option value="">Select CLO</option>
<?php
while($rs=$results->fetch_assoc()) {
?>
<option value="<?php echo $rs["id"]; ?>"><?php echo $rs["clo"]; ?></option>
<?php
}
?>
解决方案
推荐阅读
- varnish - 无法在另一个导演中使用清漆导演
- amazon-web-services - AWS Lex 提供多种用户选择选项
- node.js - Nodejs:尝试链接外部库:ReferenceError:未定义窗口
- android - 操作栏下方的 Android 布局
- android - Android - 如何获取设备使用的内存和存储空间?
- java - Google Cloud Functions 上的 Spring Cloud Functions - 部署失败
- javascript - 每1秒将实时数据从nodejs中的sql数据库传递到html的最简单方法
- php - 你如何在 PHP 中无头运行 Selenium?
- javascript - chrome 找不到脚本 src 链接
- discord.py - 如何在 discord.py 中返回特定语音频道中的成员列表?