it won't work! getJSON uses ajax... ajax can't go to another site.
On 6/20/07, LVCHEN <[EMAIL PROTECTED]> wrote:
I am doing some hack for blogger. Blogger API has offered JSON feed for user to load recent posts. This allows you to query a blog's public feed and get the resulting entries returned as JSON objects. The way to use the new JSON feed is creating a script element whose src value is http://blogname.blogspot.com/feeds/posts/default?alt=json-in-script&callback=myFunc where blogname is the blog you want to retrieve, and myFunc is the name of your callback function that is passed the JSON object. http://code.google.com/apis/gdata/json.html Now I am confused with this json-in-script and json A simple example shows the usage ///////////////////////// function a_comprc(a,b) { order= Date.parse(a.published.$t.replace(/^(\d{4})-(\d{2})- (\d{2})T([0-9:]*)([.0-9]*)(.)(.*)$/, '$1/$2/$3 $4 GMT')) - Date.parse(b.published.$t.replace(/^(\d{4})-(\d{2})- (\d{2})T([0-9:]*)([.0-9]*)(.)(.*)$/, '$1/$2/$3 $4 GMT')); return 0-order; } function a_rc(json) { g_szComments = json.feed.entry.sort(a_comprc); } document.write('<script src="http://' + g_szBlogDomain + '/ feeds/comments/default?alt=json-in- script&callback=a_rc"></script>'); ///////////////////////// If I use $.getJSON, will I get the same result? What is the difference between these two method? function a_comprc(a,b) { order= Date.parse(a.published.$t.replace(/^(\d{4})-(\d{2})- (\d{2})T([0-9:]*)([.0-9]*)(.)(.*)$/, '$1/$2/$3 $4 GMT')) - Date.parse(b.published.$t.replace(/^(\d{4})-(\d{2})- (\d{2})T([0-9:]*)([.0-9]*)(.)(.*)$/, '$1/$2/$3 $4 GMT')); return 0-order; } jQuery.getJSON( 'http://' + g_szBlogDomain + '/feeds/comments/default? alt=json', function(json) { g_szComments = json.feed.entry.sort(a_comprc); }) I hope I am not asking a too stupid question...
-- Ⓙⓐⓚⓔ - יעקב ʝǡǩȩ ᎫᎪᏦᎬ