我正在尝试通过 JQuery ajax 函数调用此 php 脚本。它只是返回状态 0 错误?我可能是网址或其他东西,但我不太确定。有什么建议么?
php:
<?php
require_once('classes/DbH.php');
$dbh = new Dbh('signatur_stories');
$dbh->query("set names utf8;");
$videoUrl = $_GET['videourl'];
echo 'jeg er et php script!!';
if(isset($videoUrl) && !empty($videoUrl)){
$sql = sprintf('UPDATE podcast SET isValidated=1 WHERE url="%s"', $videoUrl);
$dbh->query($sql);
}
?>
JS:
function validateVideo(){
alert(player.currentSrc.substring(57));
$.ajax({ url: '/../inc/validatePodcast.php',
type: 'get',
data: 'videourl=' + player.currentSrc.substring(57),
success: function() {
alert("hej");
window.location.href="../staff/admin.php";
},
error: function(jqXHR, exception) {
if (jqXHR.status === 0) {
alert('Not connect.\n Verify Network.');
} else if (jqXHR.status == 404) {
alert('Requested page not found. [404]');
} else if (jqXHR.status == 500) {
alert('Internal Server Error [500].');
} else if (exception === 'parsererror') {
alert('Requested JSON parse failed.');
} else if (exception === 'timeout') {
alert('Time out error.');
} else if (exception === 'abort') {
alert('Ajax request aborted.');
} else {
alert('Uncaught Error.\n' + jqXHR.responseText);
}
}
});
}