Created
May 22, 2014 14:16
-
-
Save cognitom/9e99b1125d9a3484d22b to your computer and use it in GitHub Desktop.
PhantomJSでAjax結果を取得する ref: http://qiita.com/cognitom/items/123f1d0e0d8e3a2ed936
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| page = (require 'webpage').create() | |
| url = '#' | |
| page.open "http://localhost:3000/", -> | |
| page.evaluate (url) -> | |
| $.ajax url: url, success: (str) -> window.ajaxResult = str | |
| , url | |
| timer = -> | |
| result = page.evaluate -> window.ajaxResult | |
| unless result | |
| window.setTimeout timer, 500 # 500ms ごとにポーリングして確認 | |
| else | |
| console.log result | |
| phantom.exit() | |
| timer() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment