How to call the Method in Jquery's Append Method ?
I have the HTML code in which I use the append method() on click of a button. I want to append the HTML with viewbag data using loop. here is my code , is that right ?
        <html>
        <body>
        <div class="row-fluid" id="MyCode">
        </div>
        <button name="AddCode"></button>
        </body>
        </html>
         <script type="text/javascript">
         $(document).ready(function ()
           {
               $('#AddCode').click(function () {
                     $('#MyCode').append("<di ><div class='span2'>" +
                      //I want to call the function here... 
                     AddDivs()
           );
        });
 function AddDivs()
 {
  var ht="";
  @foreach (var item in ViewBag.LocationList)
{
 ht += "<div id='"+item.Id+"_"+item.Name+"'></div>";
  }
  }
 });
 </script>
Its showing undefined.