2011-03-30 77 views
0

我已經寫了一個AJAX調用,但工作正常,但成功運行螢火蟲後,顯示錯誤:http://localhost:8000/js/main.js永久移動和404。但爲什麼當它調用返回成功時搜索js文件。我的ajax拋出404錯誤?

我的Ajax:

$.ajax({ 

     type:'POST', 

     url:"/foobar/", 

     data:{"foo": bar}, 

     success:function(data) { 

      $('#wrapper').html(data); 

     } 

     }); 

第一反應:

<head> 
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 
<title>Mailserved</title> 
<link href="css/new-master.css" rel="stylesheet" type="text/css" /> 
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script> 
<script src="scripts/jquery.editinplace.js"></script> 
<script src="scripts/main.js" type="text/javascript"></script> 
</head 
<body> 
// Here body ....... 
</body> 

第二次迴應

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
<html lang="en"> 
<head> 
    <meta http-equiv="content-type" content="text/html; charset=utf-8"> 
    <title>Page not found at /foobar/js/main.js/</title> 
    <meta name="robots" content="NONE,NOARCHIVE"> 
    <style type="text/css"> 
    html * { padding:0; margin:0; } 
    body * { padding:10px 20px; } 
    body * * { padding:0; } 
    body { font:small sans-serif; background:#eee; } 
    body>div { border-bottom:1px solid #ddd; } 
    h1 { font-weight:normal; margin-bottom:.4em; } 
    h1 span { font-size:60%; color:#666; font-weight:normal; } 
    table { border:none; border-collapse: collapse; width:100%; } 
    td, th { vertical-align:top; padding:2px 3px; } 
    th { width:12em; text-align:right; color:#666; padding-right:.5em; } 
    #info { background:#f6f6f6; } 
    #info ol { margin: 0.5em 4em; } 
    #info ol li { font-family: monospace; } 
    #summary { background: #ffc; } 
    #explanation { background:#eee; border-bottom: 0px none; } 
    </style> 
</head> 
<body> 
    <div id="summary"> 
    <h1>Page not found <span>(404)</span></h1> 
    <table class="meta"> 
     <tr> 
     <th>Request Method:</th> 
     <td>GET</td> 
     </tr> 
     <tr> 
     <th>Request URL:</th> 
     <td>http://localhost:8000/foobar/send/js/main.js/</td> 
     </tr> 
    </table> 
    </div> 
    <div id="info"> 

     <p></p> 

    </div> 

    <div id="explanation"> 
    <p> 
     You're seeing this error because you have <code>DEBUG = True</code> in 
     your Django settings file. Change that to <code>False</code>, and Django 
     will display a standard 404 page. 
    </p> 
    </div> 
</body> 
</html> 

    </html> 

觀察:

<th>Request URL:</th> 
      <td>http://localhost:8000/foobar/send/js/main.js/</td> 

這可能會導致問題,這是爲什麼來了,如何解決

+0

呼叫是否成功完成?您打電話的網址是否存在? – JohnP 2011-03-30 06:28:19

+0

缺少的腳本可能完全獨立於ajax調用。你是積極的,沒有別的東西試圖調用這個腳本?如果你不做ajax調用(註釋掉)並加載頁面,你還能得到404嗎? – jon3laze 2011-03-30 06:35:06

+0

隨機猜測:你有你的ajax代碼寫在這個'main.js'文件中,並且你得到錯誤404,因爲它試圖從'http:// localhost:8000/foobar /'尋找一個缺失的頁面,錯誤是來自'main.js',所以錯誤代碼顯示爲'404 ....永久移動'?請注意,您的網址以'/' – 2011-03-30 06:36:48

回答

0

目錄索引是缺失的配合。

檢查你的/ foobar的內部/ index.html的對等(或其他目錄索引喲有)

PS:永久移動是不是4004的錯誤。 404是文件未找到

+0

@thank,但我的意思是,首先它告訴我,文件移動比下一行permanantly告訴我文件沒有找到 – user12345 2011-03-30 06:51:09