30 July Fri, 2010

Base AJAX Codes and Examples

{”responseData”: { “feed”: { “title”: “Digg”, “link”: “http://digg.com/”, “author”: “”, “description”: “Digg”, “type”: “rss20″, “entries”: [ { "title": "The Pirate Bay Moves Servers to Egypt Due to Copyright Laws", "link": "http://digg.com/tech_news/The_Pirate_Bay_Moves_Servers_to_Egypt_Due_to_Copyright_Laws", "author": "", "publishedDate": "Mon, 31 Mar 2008 23:13:33 -0700", "contentSnippet": "Due to the new copyright legislation that are going ...", "content": "Due to the new copyright legislation that are going to take...", "categories": [ ] }, { “title”: “Millions Dead/Dying in Recent Mass-Rick-Rolling by YouTube.”, “link”: “http://digg.com/comedy/Millions_Dead_Dying_in_Recent_Mass_Rick_Rolling_by_YouTube”, “author”: “”, “publishedDate”: “Mon, 31 Mar 2008 22:53:30 -0700″, “contentSnippet”: “Click on any u0022Featured Videosu0022. When will the insanity stop?”, “content”: “Click on any u0022Featured Videosu0022. When will the insanity stop?”, “categories”: [ ] }, … ] }}, “responseDetails”: null, “responseStatus”: 200}In addition to this response format, the protocol also supports a classic JSON-P style callback which is triggered by specifying a callback argument. When this argument is present, the JSON object is delivered as an argument to the specified callback.

curl -e http://www.my-ajax-site.com
‘http://ajax.googleapis.com/ajax/services/feed/load?q=http%3A%2F%2Fwww.digg.com%2Frss%2Findex.xml&v=1.0&callback=foo’
This command performs a Feed Load that is identical to the previous load, BUT has been altered to pass callback. With this argument in place, instead of a JSON object being returned, a Javascript call is returned in the response and the JSON object is passed via the results parameter.

foo({”responseData”: { “feed”: { “title”: “Digg”, “link”: “http://digg.com/”, “author”: “”, “description”: “Digg”, “type”: “rss20″, “entries”: [ { "title": "The Pirate Bay Moves Servers to Egypt Due to Copyright Laws", "link": "http://digg.com/tech_news/The_Pirate_Bay_Moves_Servers_to_Egypt_Due_to_Copyright_Laws", "author": "", "publishedDate": "Mon, 31 Mar 2008 23:13:33 -0700", "contentSnippet": "Due to the new copyright legislation that are going ...", "content": "Due to the new copyright legislation that are going to take...", "categories": [ ] }, { “title”: “Millions Dead/Dying in Recent Mass-Rick-Rolling by YouTube.”, “link”: “http://digg.com/comedy/Millions_Dead_Dying_in_Recent_Mass_Rick_Rolling_by_YouTube”, “author”: “”, “publishedDate”: “Mon, 31 Mar 2008 22:53:30 -0700″, “contentSnippet”: “Click on any u0022Featured Videosu0022. When will the insanity stop?”, “content”: “Click on any u0022Featured Videosu0022. When will the insanity stop?”, “categories”: [ ] }, … ] }}, “responseDetails”: null, “responseStatus”: 200})And finally, the protocol supports callback and context arguments. When these url arguments are specified, the response is encoded as a direct Javascript call with a signature of: callback(context, feed, status, details, unused). Note the slight difference in the following command and response.

curl -e http://www.my-ajax-site.com
‘http://ajax.googleapis.com/ajax/services/feed/load?q=http%3A%2F%2Fwww.digg.com%2Frss%2Findex.xml&v=1.0&callback=foo&context=bar’
This command performs a Feed load and is identical to the previous load, BUT has been altered to pass both callback and context. With these arguments in place, instead of a JSON object being returned, a Javascript call is returned in the response and the JSON object is passed via the feed parameter.

foo(’bar’, { “feed”: { “title”: “Digg”, “link”: “http://digg.com/”, “author”: “”, “description”: “Digg”, “type”: “rss20″, “entries”: [ { "title": "The Pirate Bay Moves Servers to Egypt Due to Copyright Laws", "link": "http://digg.com/tech_news/The_Pirate_Bay_Moves_Servers_to_Egypt_Due_to_Copyright_Laws", "author": "", "publishedDate": "Mon, 31 Mar 2008 23:13:33 -0700", "contentSnippet": "Due to the new copyright legislation that are going ...", "content": "Due to the new copyright legislation that are going to take...", "categories": [ ] }, { “title”: “Millions Dead/Dying in Recent Mass-Rick-Rolling by YouTube.”, “link”: “http://digg.com/comedy/Millions_Dead_Dying_in_Recent_Mass_Rick_Rolling_by_YouTube”, “author”: “”, “publishedDate”: “Mon, 31 Mar 2008 22:53:30 -0700″, “contentSnippet”: “Click on any u0022Featured Videosu0022. When will the insanity stop?”, “content”: “Click on any u0022Featured Videosu0022. When will the insanity stop?”, “categories”: [ ] }, … ] }}, 200, null)Code SnippetsNew!
The AJAX Search API documentation includes a small collection of code snippets that demonstrate access to the service from Flash, Java, and Php. The language specific part of this is uniform across all of the AJAX APIs so instead of repeating the snippets, please view via this link.
For complete documentation on this interface, please visit the class reference manual.

Security Notes
JavaScript uses the Same-Origin Policy (SOP) to prevent malicious scripts from accessing private user data. See the Security for GWT Applications article for an in-depth discussion on the implications of this policy and other JavaScript security issues.

The AJAX Feed API does not send any private information to the host of the requested feeds (e.g., digg.com). Google’s crawler Feedfetcher downloads the feeds anonymously, and Google’s servers act as a cache for that feed for all requests made with the AJAX Feed API. The AJAX Feed API only provides access to publicly accessible feeds.

Troubleshooting
If you encounter problems with your code:

Make sure your API key is valid.
Look for typos. Remember that JavaScript is a case-sensitive language.
Use a JavaScript debugger. In Firefox, you can use the JavaScript console or the FireBug extension. In IE, you can use the Microsoft Script Debugger.
Search the AJAX APIs discussion group. If you can’t find a post that answers your question, post your question to the group along with a link to a web page that demonstrates the problem.

Pages: 1 2 3

Tags: , ,

  • PHP and MySQL 5

    Beginning PHP 5 and MySQL: From Novice to Professional offers a comprehensive introduction to two of the most popular open source technologies on the planet: the PHP scripting language and the MySQL database server.

    Read More | Postd by Ltm.ming
  • Base AJAX Codes and Examples

    Make your Web pages stand out above the noise with JavaScript and the expert instruction in this much-anticipated update to the bestselling JavaScript Bible.

    Read More | Postd by Ltm.ming
  • Mastering CSS with DW CS3

    Durch Integration von Datenbankanbindung und Skriptsprachen wird Dreamweaver CS 4 zum alltagstauglichen Werkzeug für die Erstellung einfacher Redaktionssysteme.

    Read More | Postd by Ltm.ming
  • Pro JavaScript Techniques

    Pro JavaScript Techniques is the ultimate JavaScript book for the modern web developer. It provides everything you need to know about modern JavaScript, and shows what JavaScript can do for your web sites.

    Read More | Postd by Ltm.ming
  • MySQL 5.0 Certification Study Guide

    This book is a very comprehensive guide to what MySQL offers and can teach you. br / br /Would definitely recommend for anyone needing a great book about MySQL.

    Read More | Postd by Ltm.ming
fashion handbags wow gold Hermes Birkin Bags Knockoff bag air max 2010 chanel handbags cheap golf clubs