2008-12-19 16 views
2

我正在開發一些asp.net mvc框架測試版的ajax東西。Sys.ArgumentUndefinedException:值不能undefined

但是,我得到了以下異常。 任何人都有像我這樣的問題?

Sys.ArgumentUndefinedException:值不能是未定義的。

和我的源代碼是這樣的。

<asp:Content ID="indexContent" ContentPlaceHolderID="MainContent" runat="server"> 

<script src="../../Scripts/jquery-1.2.6.js" type="text/javascript"></script> 
<script src="../../Scripts/MicrosoftAjax.debug.js" type="text/javascript"></script> 
<script src="../../Scripts/MicrosoftMvcAjax.debug.js" type="text/javascript"></script> 

<script type="text/javascript"> 
    var myView; 

    $(pageLoad); 

    function pageLoad() { 
     myView = $create(Sys.UI.DataView, {}, {}, {}, $get("ajaxResult")); 
     $("#callAjaxButton").click(callActionMethod); 
    } 

    function callActionMethod() { 
     $.getJSON("/Home/GetCategories", bindData); 
    } 

    function bindData(data) { 
     myView.set_data(data); 
    } 

</script> 

<input type="button" id="callAjaxButton" value="ajaxCall" /> 

<div id="ajaxResult"></div>  

</asp:Content> 

回答

1

從片段您提供有一對夫婦的事情要考慮:

你可以試試這個,看看它是否適合你:

<script src="../../Scripts/jquery-1.2.6.js" type="text/javascript"></script> 
<script src="../../Scripts/MicrosoftAjax.debug.js" type="text/javascript"></script> 
<script src="../../Scripts/MicrosoftMvcAjax.debug.js" type="text/javascript"></script> 
<script src="../../Scripts/MicrosoftAjaxTemplates.debug.js" type="text/javascript"></script> 

<script type="text/javascript"> 
    var myView; 

    Sys.Application.add_init(pageLoad); 

    function pageLoad() { 
     myView = $create(Sys.UI.DataView, {}, {}, {}, $get("ajaxResult")); 
     $("#callAjaxButton").click(callActionMethod); 
    } 

    function callActionMethod() { 
     $.getJSON("/Home/GetCategories", bindData); 
    } 

    function bindData(data) { 
     myView.set_data(data); 
    } 

</script> 

<input type="button" id="callAjaxButton" value="ajaxCall" /> 
<div id="ajaxResult"></div>  

Scott Hanselman寫了關於這個問題的一個很好的post