/ Published in: HTML
URL: http://code.google.com/apis/ajax/playground/#jsonp
Expand |
Embed | Plain Text
<!-- You are free to copy and use this sample in accordance with the terms of the Apache license (http://www.apache.org/licenses/LICENSE-2.0.html) --> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"/> </head> <body style="font-family: Arial;border: 0 none;"> <script type="text/javascript"> /* * A technique for avoiding browsers' cross-domain restriction * Allows you to request information cross-domain from client * You request a script from a cross domain * That service must respond in JSON wrapped in a function call you specify */ function myFunc() { if (typeof console != 'undefined') { console.log(arguments); } else { alert('click debug button'); } } var script = document.createElement('script'); script.src = 'http://ajax.googleapis.com/ajax/services/search/web?v=1.0&q=Dog&callback=myFunc'; script.type = 'text/javascript'; document.getElementsByTagName('head')[0].appendChild(script); </script> </body> </html>
You need to login to post a comment.
