title: How to update dropdown with JSON value from AJAX call using JQuery
body: <p>Hi I am receiving a JSON list in the Ajax success block and I want to assign these values to a dropdown list potentialFailureModeList present on my JSP. I am new to JSON, i have tried a lot to findout on the net but did not get anything. Please help me. Any useful link will also work.</p>
  
  <p>//Code from JSP</p>
  
  <pre><code>&lt;td&gt;&lt;select name="fmeaEntityForm[0].potentialFailureMode.id"
                              id="potentialFailureMode0" onchange="potentialFailureModeText(this)"&gt;
                                  &lt;option value="-1"&gt;&lt;spring:message code="label.fmea.select.potentialFailureMode" /&gt;&lt;/option&gt;
                                  &lt;c:forEach items="${potentialFailureModeList}" var="pfm"&gt;
                                      &lt;option value="${pfm.id}"&gt;${pfm.potentialFailureMode}&lt;/option&gt;
                                  &lt;/c:forEach&gt;
                          &lt;option value="0"&gt;&lt;spring:message code="label.fmea.select.other" /&gt;&lt;/option&gt;
                          &lt;/select&gt;&lt;/td&gt;
  </code></pre>
  
  <p>//pattern receiving in ajax</p>
  
  <pre><code>{"potentialFailureModeList":[{"id":3,"potentialFailureMode":"potentialFailureMode1","remark":"1"},
               {"id":4,"potentialFailureMode":"potentialFailureMode2","remark":"2"}]}
  </code></pre>
  
  <p>//Ajax method
  function getpotentialFailureModeList(elementIdIndex)  {</p>
  
  <pre><code>        if (-1 != document.getElementById("subSystem"+elementIdIndex+"").value)  {
  
              $.ajax({
                  type: "GET",
                  url: '/ISO26262/FmeaDocumentPage/potentialFailureModeList',
                  data: ({subSystemId : $('#subSystem'+elementIdIndex+'').val() }),
                  success: function(items) {
                      alert("success");
                      alert(items);
                      // to do task
                  },
                  error: function (e) {
                      alert('Error Received: ' + e);
                    },
              });
          } 
  }
  </code></pre>