2012-12-13 46 views
0

我有一個看起來像這樣使用jQuery的區域

<script type="text/javascript"> 
    function clickView(e) { 
     e.preventDefault(); 
     var dataItem = this.dataItem($(e.currentTarget).closest("tr")); 
     $.ajax({ 
      url: "/Jac/ViewCustomDetails", 
      data: { productId: dataItem.Id }, 
      success: function (response) { 
       $("#details").html(response); 
      }, 
      error: function (xhr, ajaxOptions, thrownError) { 
       alert(xhr.status); 
       document.write(xhr.responseText); 
      } 
     }); 
    } 
</script> 

基本上這使得AJAX調用我的控制器來呈現一個動作一個jQuery click方法中呈現從操作HTML。

行動ViewCustomDetails,這是內JacController,並在區域內是這樣的:

public ActionResult ViewCustomDetails(int productId) 
    { 
     Detail model; 

     model = new Detail 
     { 
      Price = productId.ToString(), 
      Origin = productId.ToString() 
     }; 

     return View(model); 
    } 

當我點擊我的按鈕觸發關閉AJAX調用,我能闖進我的行動。然而,我在我看來,出現此錯誤

The view 'ViewCustomDetails' or its master was not found or no view engine supports the searched locations. The following locations were searched: 
~/Views/Jac/ViewCustomDetails.aspx 
~/Views/Jac/ViewCustomDetails.ascx 
~/Views/Shared/ViewCustomDetails.aspx 
~/Views/Shared/ViewCustomDetails.ascx 
~/Views/Jac/ViewCustomDetails.cshtml 
~/Views/Jac/ViewCustomDetails.vbhtml 
~/Views/Shared/ViewCustomDetails.cshtml 
~/Views/Shared/ViewCustomDetails.vbhtml 

顯然,在我的觀點沒有這樣的控制器/操作的文件夾我的控制器是一個區域內。

如何獲取它以引用我所在地區的控制器?

回答

0

我不得不區域名稱在jQuery代碼添加到我的網址這樣

url: "/Dan/Jac/ViewCustomDetails", 

,而不是僅僅

url: "/Jac/ViewCustomDetails", 
0

它引用您的控制器,但該行return View(model);在ViewCustomDetails方法需要查看文件是否存在,這通常被稱爲ViewCustomDetails.cshtml

此查看文件必須採取的Detail

模型類型

您可能還需要JSONify返回的視圖。