如何在弹出窗口上调用json对象?

时间:2015-08-03 18:22:21

标签: javascript json jsp

我试图在弹出窗口中调用json对象但无法实现它...... 如果我错了,请建议我。 我的html文件在这里:

<html>

<head>
  <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/themes/ui-darkness/jquery-ui.css" rel="stylesheet">
  <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
  <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/jquery-ui.min.js"></script>
  <script type="text/javascript">
    function advanceSearch() {
      $("#test").dialog({

        width: '90%',
        modal: true
      });
    }

    function getInformation() {
      alert("hello");
      $.ajax({
        url: "/response.json",
        dataType: "json",
        type: "GET",
        success: function(response) {
          alert("hello2");
          $.each(response.BankAccounts, function(item) {
            informationArray.push(item);
            alert(data[0].bank)
          });
          informationArray.push("success");
        }
      });
    }
  </script>
</head>

<body>
  <form id="BankAccounts" name="BankAccounts">
    Sort Code :
    <input type="text" name="sortCode1" />
    <br>
    <input type="text" name="sortCode2" />
    <br>
    <input type="text" name="sortCode3" />
    <br>
    <input type="button" id="search" value="Search" onclick="getInformation()"> Bank Name :
    <input type="text" name="bank" />
    <br> Branch Name :
    <input type="text" name="branch" />
    <br>
  </form>
  <div id="test" style="display: none;">
    This is a sample content
  </div>
</body>

</html>

我的json在这里:

{
  "BankAccounts": [{
      "bank": "HSBC"
      "branch": "nlbc road"
    }, {
      "bank": "BOA"
      "branch": "New York"
    }

  ]
}

点击我想在弹出窗口中调用银行名称

0 个答案:

没有答案