2012-06-29 76 views
0

我跟着這個tutorial,把js,css和gif放在相應的文件夾中。問題是視圖不顯示一個東西。使用Valums的ASP.NET MVC文件上傳Ajax Uploader沒有視圖創建

<link href="@Url.Content("~/css/fileuploader.css")" rel="stylesheet" type="text/css" /> 
<script src="@Url.Content("~/js/fileuploader.js")" type="text/javascript"></script> 
<div id="file-uploader"> 
    <noscript> 
     <p> 
      Please enable JavaScript to use file uploader.</p> 
    </noscript> 
</div> 
<script type="text/javascript"> 
var uploader = new qq.FileUploader({ 
element: document.getElementById('file-uploader'), 
action: '@Url.Action("upload")' // put here a path to your page to handle uploading 
//,allowedExtensions: ['jpg', 'jpeg', 'png', 'gif'] // user this if you want to upload only pictures 
sizeLimit: 4000000, // max size, about 4MB 
minSizeLimit: 0 // min size 

}); 
</script> 

這個腳本有什麼問題?

隨着螢火蟲產生的誤差是

missing } after property list 

頁源

<!DOCTYPE html> 
<html> 
<head> 
    <meta charset="utf-8" /> 
    <title>Home Page</title> 
    <link href="/Content/Site.css" rel="stylesheet" type="text/css" /> 
    <script src="/Scripts/jquery-1.5.1.min.js" type="text/javascript"></script> 
    <script src="/Scripts/modernizr-1.7.min.js" type="text/javascript"></script> 
</head> 
<body> 
    <div class="page"> 
     <header> 
      <div id="title"> 
       <h1>My MVC Application</h1> 
      </div> 
      <div id="logindisplay"> 
        [ <a href="/Account/LogOn">Log On</a> ] 

      </div> 
      <nav> 
       <ul id="menu"> 
        <li><a href="/">Home</a></li> 
        <li><a href="/Home/About">About</a></li> 
       </ul> 
      </nav> 
     </header> 
     <section id="main"> 
      <link href="/css/fileuploader.css" rel="stylesheet" type="text/css" /> 
<script src="/js/fileuploader.js" type="text/javascript"></script> 
<div id="file-uploader"> 
    <noscript> 
     <p> 
      Please enable JavaScript to use file uploader.</p> 
    </noscript> 
</div> 
<script type="text/javascript"> 
var uploader = new qq.FileUploader({ 
element: document.getElementById('file-uploader'), 
action: '/Home/upload' // put here a path to your page to handle uploading 
//,allowedExtensions: ['jpg', 'jpeg', 'png', 'gif'] // user this if you want to upload only pictures 
sizeLimit: 4000000, // max size, about 4MB 

minSizeLimit: 0 // min size 

}); 
</script> 

     </section> 
     <footer> 
     </footer> 
    </div> 
</body> 
</html> 
+0

什麼是生成的來源?你在Firebug中看到了什麼? – SLaks

+0

我已經添加了生成的源代碼。查看編輯。 – nebula

回答

0

你有一個結尾逗號在這裏,你應該刪除:

minSizeLimit: 0, // min size 

你這裏忘了一個逗號:

action: '@Url.Action("upload")' // put here a path to your page to handle uploading 

所以請努力編寫有效的javascript:

<script type="text/javascript"> 
    var uploader = new qq.FileUploader({ 
     element: document.getElementById('file-uploader'), 
     action: '@Url.Action("upload")', 
     sizeLimit: 4000000, 
     minSizeLimit: 0 
    }); 
</script> 

啊,我現在可以看到你有複製粘貼從文章包含了同樣的錯誤。對不起,我認爲這是你的錯誤。隨意通知本文作者有關他的代碼中的錯誤。

+0

它現在都工作了。謝謝。問題是我在行動後錯過了逗號。 – nebula

+0

較早的評論是爲你的第一個答案。無論如何,我現在刪除它。 – nebula

相關問題