2012-06-01 21 views
0

我有這個jQuery應該解僱MVC函數調用,功能不是在MVC從jstree呼叫發射

$(document).ready(function() { 
alert("ddddd"); 
$("#divJsTreeDemo").jstree({ 
    "plugins": ["json_data"], 
    "json_data": { 
     "ajax": { 
      "type": "POST", 
      "url": "/WebTree/GetTreeNodes", 
      "async": true, 
      "contentType": "application/json; charset=utf-8", 
      "dataType": "json", 

      "data": function (node) { 

       return ""; 

      }, 
      sucess: function (retval) { 
       var d = ""; 
      }, 
      error: function (retval) { 
       alert(retval); 
      } 
     } 
    } 

}); 

}); 

但我不斷收到一個錯誤說「您正在查找的資源已被刪除,有其名稱已更改,或者暫時不可用。「

當我將它發送到服務器時,我得到的json錯誤嗎?

這裏是MVC控制器,

Public Class WebTreeController 
    Inherits System.Web.Mvc.Controller 

    ' 
    ' GET: /WebTree 

    Function Index() As ActionResult 
     Return View() 
    End Function 

    Public Function GetTreeNodes() As JsonResult 

     Dim list As New List(Of String) 
     list.Add("dddd") 

     'Dim jsonString As String = Encoding.Default.GetString(list.ToArray) 

     Return Me.Json(list) 

    End Function 


End Class 
+0

嘗試在數據中發送NULL,也請確保url正確。 –

回答

1

幾件事情:

  1. 在瀏覽器中直接輸入網址,看看你得到的結果。如果不是,它可能是一個路由問題,但不太可能。
  2. 使用瀏覽器的開發人員工具(在Chrome/IE中按F12鍵)並檢查正在進行的請求。這個問題是一個URL問題的99.9%。
  3. 在您的視圖中使用@ Url.Action()來生成操作的路徑,而不是硬編碼的鏈接。路徑可能會根據您的部署配置而改變。

乾杯。