1ヶ月ほど前に質問laravelのajax通信を質問させて頂きました。
その時の質問を応用したようなことをしたいと思っています。。
この時の質問は1つの単語の場合を質問したのですが、これを複数の単語を抽出したい場合はどうすればよろしいでしょうか?
質問した時のURLとソースコードです。
https://teratail.com/questions/24937
javascript
1$(document).ready(function() { 2var test = $('p').text(); 3 $.ajax({ 4 url:'http://exsample.com/search?', 5 data : { 6 'word' : test, 7 }, 8 type: "GET", 9 dataType : "text", 10 success : function(data){ 11 console.log('success:'+data); 12 }, 13 error : function(data){ 14 console.log(data); 15 console.log('error:'+data.data); 16 } 17 }); 18 });
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" } }
これを
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" } [1]=> object(stdClass)#332 (6) { ["id"]=> int(3) ["word2"]=> string(18) "hogehoge" ["content"]=> string(155) "hogehoge2" ["created_at"]=> string(19) "2016-01-01 00:00:00" ["updated_at"]=> string(19) "2016-01-01 00:00:00" } }
のように複数の取得したい場合の処理の仕方を、ご存知でしたら教えてください!
よろしくお願いします。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/02/18 02:09
退会済みユーザー
2016/02/18 17:25