2013-06-11 98 views
0

我想通過jQuery ajax函數調用這個php腳本。它只是返回狀態0錯誤?我可能是網址或其他東西,但我不太確定。有什麼建議麼?JQuery Ajax GET函數

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); 
       } 
      } 
     }); 
    } 
+0

嘗試直接路徑爲url – Johnny000

+0

什麼返回0? –

+0

我已經嘗試了直接路徑,它也是一樣的 –

回答

1

網址: '/.. /inc/validatePodcast.php'

是正確的嗎?

+0

它不是,我刪除了第一個斜槓:) –