Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/376.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在弹出窗口中调用json对象?_Javascript_Json_Jsp - Fatal编程技术网

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

Javascript 如何在弹出窗口中调用json对象?,javascript,json,jsp,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.googleap

我正试图在弹出窗口中调用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对象是什么意思?你的Json文件无效。No
$(document)。ready(function(){})
No jQueryYou需要在Json中用逗号描述对象属性,请尝试使用@Daniel_L,你能给我举个例子吗?由于我是新手,“调用”Json对象是什么意思?您的Json文件无效。No
$(document)。ready(function(){})
No jqueryy您需要在Json中用逗号描述对象属性,请尝试使用@Daniel\L您能给我举个例子吗?因为我是新手
{
  "BankAccounts": [{
      "bank": "HSBC"
      "branch": "nlbc road"
    }, {
      "bank": "BOA"
      "branch": "New York"
    }

  ]
}