Click here to Skip to main content
15,886,919 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
In my controller action method I am adding the below code I am passing list data after binding it
public JsonResult GetMonthByYear(int Year)
{
return Json(new { ListMonths = Months});

}
in view when I want retrieve the length of the list I am getting the error as Jquery is undefined
for(int ind=0;ind<result.length;ind++) function="" yearchange()="" {="" var="" stryear="document.getElementById("Year_ID").value;" if="" ((stryear)="" !=""")" alert(stryear);="" options="{};" options.url=""/PO/GetMonthByYear";" options.type=""POST";" options.datatype=""json";" options.data="{" year:="" $(&quot;#year_id&quot;).val()="" };="" options.success="function" (result)="" teams="eval('('" +="" result.value="" &#39;)&#39;);="" listitems=""";" lstmonths="result.ListMonths;" length="result.ListMonths.length;" alert(length);="" alert(lstmonths.length);="" for(int="" ind="0;ind<result.length;ind++)" alert(&quot;hello&quot;);="" }="" $.ajax(options);="" i="" added="" the="" below="" references="" <script="" src=""~/Scripts/jquery-1.8.3.js"" type=""text/javascript"></script>" &lt;script="">

Please let me know what should I do to resolve thi?

What I have tried:

Javascript method showing error
Posted
Updated 30-Nov-16 2:39am
Comments
Kornfeld Eliyahu Peter 30-Nov-16 9:00am    
The code you copied here... How that connected?
F-ES Sitecore 30-Nov-16 9:49am    
Update the question so that the code is properly formatted, however if the issue is that jquery is not defined then check the network tab of the browser tools to ensure your jQuery js file is loading and ensure the script tag is above the code in the page layout.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900