Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/424.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 Localhost jquery.google-search-master控制台错误-$。GoogleSearch不是构造函数_Javascript_Jquery_Json_Node.js_Autocomplete - Fatal编程技术网

Javascript Localhost jquery.google-search-master控制台错误-$。GoogleSearch不是构造函数

Javascript Localhost jquery.google-search-master控制台错误-$。GoogleSearch不是构造函数,javascript,jquery,json,node.js,autocomplete,Javascript,Jquery,Json,Node.js,Autocomplete,我在端口3000上有一个localhost服务器,我使用node.js和express在本地运行一个网站。一般来说,我对编码相当陌生,最近才学会这些框架,所以我可能对概念缺乏重要的理解,但在网上搜索了很多之后,我已经走到了死胡同 我想操纵我的网站上谷歌搜索的数据,特别是从表单中获取cityname数据,将其发送到谷歌搜索,然后将数据取回。现在,我只想查看返回数据的console.log,看看它告诉了我什么,为此,我找到了一个很好的存储库: 下载ZIP后,我尝试将文件合并到我自己的文件夹层次结构

我在端口3000上有一个localhost服务器,我使用node.js和express在本地运行一个网站。一般来说,我对编码相当陌生,最近才学会这些框架,所以我可能对概念缺乏重要的理解,但在网上搜索了很多之后,我已经走到了死胡同

我想操纵我的网站上谷歌搜索的数据,特别是从表单中获取cityname数据,将其发送到谷歌搜索,然后将数据取回。现在,我只想查看返回数据的console.log,看看它告诉了我什么,为此,我找到了一个很好的存储库:

下载ZIP后,我尝试将文件合并到我自己的文件夹层次结构中,将文件复制到我自己的文件夹中,如下所示:

我将jquery.google-search.min.js、jquery-1.7.2.min.js、jquery.google-search.spec.js、jquery.google-search.js和buster.js放入我的js文件夹“public”下

所有这些都是我放在文件夹中的ZIP文件,但还有一些其他文件,如“.travis.yml”或“package.json”或“compiler.jar”,我没有复制它们。我有自己的package.json文件,其中包含以下内容:

{
  "name": "myapp",
  "version": "0.0.0",
  "private": true,
  "scripts": {
    "start": "node ./bin/www"
  },
  "dependencies": {
    "body-parser": "~1.15.1",
    "cookie-parser": "~1.4.3",
    "debug": "~2.2.0",
    "nodemailer": "2.5.0",
    "express": "~4.13.4",
    "ejs": "~2.4.2",
    "morgan": "~1.7.0",
    "serve-favicon": "~2.3.0"
  }
}
jquery.google-search中的package.json是:

{
  "author": "Sascha Depold <sascha@depold.com> (htp://depold.com)",
  "name": "jquery.google-search",
  "description": "Execute google searches within your client-side javascript.",
  "version": "0.1.4",
  "homepage": "https://github.com/sdepold/jquery.google-search",
  "repository": {
    "type": "git",
    "url": "git://github.com/sdepold/jquery.google-search.git"
  },
  "dependencies": {},
  "devDependencies": {
    "jquery.skeleton": "~0.6.0",
    "buster": "~0.6.2"
  },
  "optionalDependencies": {},
  "engines": {
    "node": "*"
  },
  "scripts": {
    "test": "npm run minify && npm run buster-test",
    "buster-test": "node_modules/.bin/buster-test",
    "buster-capture": "(npm run buster-server &) && sleep 2 && npm run buster-capture-browser",
    "minify": "java -jar dist/compiler.jar src/*.js --js_output_file=dist/jquery.`pwd|sed -e 's/.*jquery\\.//'`.min.js",
    "buster-capture-browser": "type -P open &>/dev/null && open 'http://localhost:1111/capture' || firefox 'http://localhost:1111/capture'",
    "buster-server": "node_modules/.bin/buster-server"
  },
  "main": "src/jquery.google-search.js"
}
{
“作者”:“萨沙·德波尔德”(htp://depold.com)",
“名称”:“jquery.google search”,
“描述”:“在客户端javascript中执行谷歌搜索。”,
“版本”:“0.1.4”,
“主页”:https://github.com/sdepold/jquery.google-search",
“存储库”:{
“类型”:“git”,
“url”:”git://github.com/sdepold/jquery.google-search.git"
},
“依赖项”:{},
“依赖性”:{
“jquery.skeleton”:“~0.6.0”,
“巴斯特”:“~0.6.2”
},
“可选依赖项”:{},
“发动机”:{
“节点”:“*”
},
“脚本”:{
“测试”:“npm运行缩小和npm运行破坏测试”,
“buster测试”:“node_modules/.bin/buster测试”,
“buster capture”:(npm运行buster server&&&sleep 2&&npm运行buster capture浏览器),
“minify”:“java-jar dist/compiler.jar src/*.js--js_output_file=dist/jquery.`pwd|sed-e's/*jquery\\\./'`.min.js”,
“buster捕获浏览器”:“键入-P open&>/dev/null&&open”http://localhost:1111/capture“| | firefox”http://localhost:1111/capture'",
“buster服务器”:“节点\模块/.bin/buster服务器”
},
“main”:“src/jquery.google search.js”
}
我不知道我是否应该复制其他文件或使用json做些什么。。。这甚至可能不是问题所在。还有一个名为“MIT-LICENSE”的文件,我不确定是否需要它

在任何情况下,一旦我启动服务器并转到本地主机,并在表单中写入一些文本,控制台(我有Firefox)就会显示:

为了通过表单查找城市,我使用了geobytes自动完成小部件

我的相关代码如下:

<script type="text/javascript" src="js/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="js/jquery.google-search.js">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js" type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script>

<!-- Autocomplete Cities -->
    <script>
    jQuery( function () {
      var find;

      function getCityDetails (cityname) {  //this is a function I created
        jQuery.getJSON(
          "http://gd.geobytes.com/GetCityDetails?callback=?&fqcn="+cityname,
            function searchGoogle (data) {
              find = new $.GoogleSearch().search(city + " weather", {}, function(data) {
              console.log(find);
              })
            }
         );
      }

     jQuery("#f_elem_city").autocomplete({

      source: function (request, response) {
       jQuery.getJSON(
        "http://gd.geobytes.com/AutoCompleteCity?callback=?&q="+request.term,
        function (data) {
          response(data);
        }
       );
      },
      minLength: 3,
      select: function (event, ui) {
       var selectedObj = ui.item;
       jQuery("#f_elem_city").val(selectedObj.value);
       getCityDetails(selectedObj.value); //this is a function I created
       return false;
      },
      open: function () {
       jQuery(this).removeClass("ui-corner-all").addClass("ui-corner-top");
      },
      close: function () {
       jQuery(this).removeClass("ui-corner-top").addClass("ui-corner-all");
      }

     });

     jQuery("#f_elem_city").autocomplete("option", "delay", 100);

    });
  </script>

jQuery(函数(){
var发现;
函数getCityDetails(cityname){//这是我创建的一个函数
jQuery.getJSON(
"http://gd.geobytes.com/GetCityDetails?callback=?&fqcn=“+城市名称,
功能搜索谷歌(数据){
find=new$.GoogleSearch().search(城市+“天气”,{},函数(数据){
console.log(find);
})
}
);
}
jQuery(“#f#elem_city”).autocomplete({
来源:功能(请求、响应){
jQuery.getJSON(
"http://gd.geobytes.com/AutoCompleteCity?callback=?&q=“+request.term,
功能(数据){
答复(数据);
}
);
},
最小长度:3,
选择:功能(事件、用户界面){
var selectedObj=ui.item;
jQuery(“#f#elem_city”).val(selectedObj.value);
getCityDetails(selectedObj.value);//这是我创建的一个函数
返回false;
},
打开:函数(){
jQuery(this).removeClass(“ui角落全部”).addClass(“ui角落顶部”);
},
关闭:函数(){
jQuery(this).removeClass(“ui角落顶部”).addClass(“ui角落全部”);
}
});
jQuery(“#f#elem_city”).autocomplete(“选项”,“延迟”,100);
});
我假设我的问题在getCityDetails或searchGoogle函数中,在其参数或位置上,在某种程度上不符合堆栈顺序,或者它是一种阻止我做我想做的事情的闭包,但通常你可以看到我从存储库复制了Google.Search代码,因此,创建该对象应该没有问题

此外,由于错误指向jquery.min.js,并且它是一个缩小的文件,我不知道问题出在哪里,但它似乎与自动完成功能有关,而不是谷歌搜索

我在这里很困惑,因为试图进一步调试它超出了我目前的知识水平。。。我们将不胜感激

谢谢

创建存储库的sdepold提醒我,与此搜索功能相关的Google API已损坏,因此无法使用。

sdepold创建存储库的sdepold提醒我,与此搜索功能相关的Google API已损坏,因此无法使用