開発環境
- OS X Lion - Apple(OS)
- Safari (Webプラウザ)
- TextWrangler(Text Editor) (BBEditの無料、light版)
- Script言語:JavaScript
- JavaScript Library: jQuery
『初めてのJavaScript 第2版』(シェリー・パワーズ著(Shelley Powers著)、武舎 広幸+武舎 るみ訳、オライリー・ジャパン、2009年、ISBN978-4-84311-425-5) の14章(Ajaxの基礎)練習問第14-5を解いてみる。
その他参考書籍
- JavaScript 第6版
- JavaScriptリファレンス 第6版
- 『jQueryクックブック』(jQuery Community Experts 著、株式会社クイープ 訳、オライリー・ジャパン、2010年、ISBN978-4-87311-468-2)
14-5.
コード(TextWrangler)
var xmlhttp = new XMLHttpRequest(); function getRecipe(){ var drink = encodeURIComponent($('#drink').val()); var url = "recipe.php?drink=" + drink; xmlhttp.open("GET", url, true); xmlhttp.onreadystatatechange = printRecipe; xmlhttp.send(null); } function printRecipe(o){ if(xmlhttp.readyState == 4 && xmlhttp.status = 200){ var text = xmlhttp.responseText; $('#recipe').text(text); } }
0 コメント:
コメントを投稿