我一直在处理一些代码并在localhost上进行测试,代码可以在本地服务器上运行,但是当我将其上传到我的服务器时它无法正常工作。
的index.php
<form action="" method="post" id="teachome">
<label>
Category</label**strong text**>
<select id="listt" type="text" name="nam" style="width:188px;" required>
<?php
$data1 = mysqli_query($con,"SELECT * FROM admin_cat");
echo "<option value=>--select--</option>";
while($rows = mysqli_fetch_array($data1)){?>
<option value="<?php echo $rows['cat']; ?>"><?php echo $rows['cat']; ?></option>
<?php } ?>
</select>
<label>Class</label>
<select id="cat" type="text" name="cls" style="width:188px;" required>
<option value="">--Select--</option>
</select>
</form>
<!--Ajax -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("#listt").change(function() {
var data = $("#teachome").serialize();
//alert(data);
$.ajax({
type: 'POST',
url: 'fetch.php',
data: data,
datatype: 'json',
success: function(data) {
var obj = jQuery.parseJSON(data);
$('#cat').empty();
$.each(obj, function(index, value) {
$("#cat").append("<option>" + value.class + "</option>");
});
}
});
});
});
</script>
Fetch.php
<?php
$cat=$_POST['nam'];
$sql= mysqli_query($con,"select * from admin_class where category='$cat'")or die(mysqli_error());
$result = mysqli_fetch_all($sql, MYSQLI_BOTH);
echo json_encode($result);
?>
在实时服务器上的响应中发生内部错误500。