我有一个PHP脚本返回前端,本地工作正常,当我上传到服务器它不再工作。有没有人知道修复或发现问题?不,它与数据库无关。
我还尝试了另一台服务器,所以我不认为它与服务器有关。
ajax get request
$(document).ready(function () {
var carid;
var tabid;
$(".button-collapse").sideNav()
$('.modal').modal();
$.ajax({
method: 'get',
url: 'api.php',
dataType: 'html',
contentType: 'application/json',
data: {
action: 'getmedisch'
}
}).done(function (data) {
接收php脚本:
switch ($_SERVER['REQUEST_METHOD']) {
case'GET':
$action = $_GET['action'];
switch ($action) {
case 'getmedisch':
$content = new Content();
$data = $content->get_content('medisch');
$value = ' <div class="col s3">
<div id="newcard" object_id="NEW" class="card new">
<div class="card-image">
<img src="asset/bold.svg" style="width: 100%; height: auto;">
<div class="card-action zero-padding">
</div>
<div class="card-content">
<h5>New Card</h5>
</div>
</div>
</div></div>';
foreach ($data as $insert) {
if($insert["online"]){$online= 'green online" ><i class="material-icons">visibility</i>';
}else{$online= 'blue offline" ><i class="material-icons">visibility_off</i>';}
$value .= '
<div class="col s3">
<div id="cardobject" object_id="' . $insert["ID"] . '" class="card">
<div class="card-image">
<img src="../asset/' . $insert["Foto"] . '" style="width: 100%; height: auto;">
<div class="card-action zero-padding">
<div class="fixed-action-btn horizontal btn-card-midle" >
<a class="btn-floating btn-large red">
<i class="large material-icons">build</i>
</a>
<ul>
<li><a class=" delete btn-floating red"><i class="material-icons">delete</i></a></li>
<li><a class=" build btn-floating yellow darken-1"><i class="material-icons">mode_edit</i></a></li>
<li><a class=" status btn-floating ' . $online .'</a></li>
</ul>
</div>
</div>
<div class="card-content">
<h5>' . $insert["Titel"] . '</h5>
</div>
</div>
</div></div>
';
}
echo $value;
break;