いつもお世話になっております。
今回の達成したいことは、単語の意味をwordというデーターベースから取ってくることです。
仕様としましては、
・http://exsample.com/hoge
というURLにアクセスしたら、そのページのp タグに囲まれている単語を抽出
・その単語をajaxでhttp://exsample.com/search
というURLにアクセスしてその単語をwordデーターベースにアクセスして単語検索で、wordにあるその単語の意味抽出
・http://exsample.com/hoge
にその単語の意味の配列を取得
以上のことをやりたいのですが、どうすればいいのでしょうか?
ajaxは下記のように書いております
$(document).ready(function() { var test = $('p').text(); $.ajax({ url:'http://exsample.com/search?', data : { 'word' : test, }, type: "GET", dataType : "text", success : function(data){ console.log('success:'+data); }, error : function(data){ console.log(data); console.log('error:'+data.data); } }); });
ajax通信の結果
array(1) { ["word"]=> array(1) { [0]=> object(stdClass)#331 (5) { ["id"]=> int(3) ["word"]=> string(18) "hoge" ["content"]=> string(155) "hogehoge" ["created_at"]=> string(19) "2016-01-01 00:00:00" ["updated_at"]=> string(19) "2016-01-01 00:00:00" } }
となり、
console.logにcontentのみを表示させたいのですがどうすればよろしいでしょうか?
どなたかご存知でしたら教えてください!
よろしくお願いいたします。
回答1件
あなたの回答
tips
プレビュー