TypeError: $(…).data(…) is undefined when trying to use first selection result

TypeError: $(…).data(…) is undefined when trying to use first selection result

I'm using autocomplete plugin to select university from an external json list. Now, it will be such that once student selects university, later he will need to choose his faculty.

For instance,

  1.     Columbia University: communityid = 11 : parentID = 0
  2.     Architecture, Planning & Preservation: communityid = 14 : parentid = 11

I dont understand why I am getting `TypeError: $(...).data(...) is undefined` error.

HTML
  1.     <form action="content/signup/index.cs.asp?Process=AddMember" method="post" class="signup-form">
  2.       <fieldset>
  3.         <p>
  4.           <input type="text" name="COMMUNITY" size="55" value="" title="<%=lngUniversity%>" />
  5.           <div id="autobox"></div>
  6.         </p>
  7.         <p>
  8.           <input type="text" name="SCHOOL" size="55" value="" title="<%=lngSchool%>" />
  9.         </p>
  10.         <p>
  11.           <input type="hidden" name="COMMUNITYEMAIL" value="">
  12.           <input type="hidden" name="COMMUNITYID" value="">
  13.           <input type="hidden" name="x" value="p">
  14.           <input type="submit" name="#" value="<%=lngSubmit%>" class="btn btn-signup">
  15.         </p>
  16.       </fieldset>
  17.     </form>
JS
  1.     $(".signup-form input[name='COMMUNITY']").autocomplete({
  2.       source: function (request, response) {
  3.         $.ajax({
  4.           url: "/content/signup/index.cs.asp?Process=CheckEmail&PARENTID=0&COMMUNITY=" + request.term,
  5.           dataType: "json",
  6.           success: function (data) {
  7.             response($.map(data.CheckEmail, function (item) {
  8.               return {
  9.                 label: item.Name,
  10.                 value: item.Name,
  11.                 CommunityID: item.CommunityID
  12.               }
  13.             }));
  14.           }
  15.         });
  16.       }
  17.     });
  18.     $(".signup-form input[name='SCHOOL']").autocomplete({
  19.       source: function (request, response) {
  20.         $.ajax({
  21.           url: "/content/signup/index.cs.asp?Process=Check&PARENTID=" + $(".signup-form input[name='COMMUNITY']").data(CommunityID).selectedItem.UniversityId + "&COMMUNITY=" + request.term,
  22.           dataType: "json",
  23.           success: function (data) {
  24.             response($.map(data.CheckEmail, function (item) {
  25.               return {
  26.                 label: item.Name,
  27.                 value: item.Name,
  28.                 emailURL: item.emailURL,
  29.                 SchoolID: item.CommunityID
  30.               }
  31.             }));
  32.           }
  33.         });
  34.       },
  35.       minLength: 1,
  36.       select: function (event, ui) {
  37.         $(".signup-form input[name='COMMUNITYEMAIL']").val(ui.item.emailURL);
  38.         $(".signup-form input[name='COMMUNITYID']").val(ui.item.CommunityID);
  39.       },
  40.       open: function () {
  41.         $(this).removeClass("ui-corner-all").addClass("ui-corner-top");
  42.       },
  43.       close: function () {
  44.         $(this).removeClass("ui-corner-top").addClass("ui-corner-all");
  45.       },
  46.       appendTo: '#autobox'
  47.     });