Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/421.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ajax/6.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 Ajax和googleplaceapi获取json_Javascript_Ajax_Json_Google Places Api - Fatal编程技术网

Javascript Ajax和googleplaceapi获取json

Javascript Ajax和googleplaceapi获取json,javascript,ajax,json,google-places-api,Javascript,Ajax,Json,Google Places Api,我正在制作一个简单的页面,在这里你可以在一个文本框中输入城市的名称,并显示城市的基本信息(地址、名称等)。我在使用Google Places API时遇到问题。这就是我目前所拥有的 restaurants.html <html xmlns="http://www.w3.org/1999/xhtml" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; ch

我正在制作一个简单的页面,在这里你可以在一个文本框中输入城市的名称,并显示城市的基本信息(地址、名称等)。我在使用Google Places API时遇到问题。这就是我目前所拥有的

restaurants.html

<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Restaurant Search</title>
        <link rel="stylesheet" type="text/css" href="style.css">
        <script src="jquery.js"></script>
        <script src="functions.js"></script>
        <script>
            $(document).ready(function(){
                getRestaurants();
            });
        </script>
    </head>
    <body>
        <div class="main">
            <form>
                Enter city name: <input id="city" type="text" name="cityname"><input id="btn" type="submit" value="Search">
            </form>
            <div id="error">
                The search field cannot be left empty!
            </div>
        </div>

        <div id="header">

        </div>
        <div id="items">

        </div>
    </body>
</html>
css中只有这个

#error{
    display: none;
}
有什么问题吗?

请查看此链接 只需复制代码并根据需要定制即可

#error{
    display: none;
}