私はnode.jsを使用してセットアップし、ウェブサイトをローカルで実行するように設定したポート3000上にlocalhostサーバーを持っています。私は一般的にコーディングするのがとても新しく、最近はこれらのフレームワークを学んだので、概念の重要な理解が欠落しているかもしれませんが、私は多くのオンライン検索の後で行き詰まってしまいました。
Google検索のデータを操作したいと思っています。具体的には、フォームからcitynameデータを取得し、Google検索に送信してからデータを取得します。今の私はそれはそれは私に語ったものを見るためにデータを返し、そしてそのために、私は、この素敵なリポジトリたCONSOLE.LOGたい:ZIPをダウンロードした後
https://github.com/sdepold/jquery.google-search#license
を、私は私にファイルを組み込むことを試みました
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検索でpackage.jsonをした:私が持っている必要がある場合、私は知らない
{
"author": "Sascha Depold <[email protected]> (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"
}
他のファイルをコピーしたり、jsonで何かをやったりして...それは問題ではないかもしれません。私は必要とされているとは思えない「MIT-LICENSE」というファイルもあります。いずれの場合においても
、かつて私は自分のサーバーを起動して、私のlocalhostに行く、と私は、フォームにテキスト、コンソールを(私は、Firefoxを持っている)が表示され、書き込み:
都市を見つけるための私はgeobytes autocomplete widgetを使ったフォームを使っていました。次のように
私の関連するコードは次のとおりです。
<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>
私はいくつかの方法で、スタックの順番と合わないことをそのパラメータまたはその配置で、私の問題は私のgetCityDetailsまたはsearchGoogle関数であると仮定していますそれは私が望むことをするのを妨げる一種の閉鎖ですが、一般的に私はリポジトリからGoogle.Searchコードをコピーしたことがわかります。したがって、そのオブジェクトを作成する際に問題はないはずです...
さらに、エラーはjquery.min.jsを指しているので、それは縮小されたファイルであるため、どこに問題があるのかわかりませんが、 Google検索ではなくオートコンプリート機能につながりました。
これ以上デバッグしようとすると私の知識レベルを超えてしまったので、私はここで非常に困惑しています...すべての助けをいただければ幸いです。
ありがとうございます!