[jQuery] problem of using ajax

[jQuery] problem of using ajax


Background:
I use google app (domain: www.example.com ) to save some static
pages before. Now I want to use google app engine(domain:
apps.example.com) to generate some dynamic and interactive elements
and put thoes elements in my google app static pages . I try to solve
this problem by using some solutions.
Solution 1:
Use google app engine to generate dynamic html response at
first, and then use iframe at google app static pages to link those
dynamic html, finally show those html on the browser.
Problem: the iframe size can not fit the dynamic content.
So I want to use ajax to mashup the dynamic elements in my static
pages, because the domain of my app engine is not the same as that of
my google app static pages. So, I need some special ways to solve it.
Solution 2:
In static pages (www.example.com ), I use a hiden iframe as a
proxy to connect apps.example.com.(Use ajax,not use any javascript
library)
Problem: IE\Firefox\safari is OK , but opera 9.51 does not work.
I though that my code may be not compatible to opera9.51. So, I decide
to use Jquery to create xmlhttp. When I use Jquery, If I need to cross
domain , I need to use $.getjson to get json data from
apps.example.com. So, I need google app engine to return json data.
Solution 3:
Code on server(python):
class newest(webapp.RequestHandler):
def get(self):
#get the newest Article form database and return
articles's title
and url (using json)
WebArticles = db.GqlQuery("SELECT * FROM WebArticle
ORDER BY articleDate DESC LIMIT 10")
result = []
for WebArticle in WebArticles:
article = {}
article['Title'] = WebArticle.articleTitle
article['URL'] = WebArticle.articleUrl
result.append(article)
self.response.out.write(simplejson.dumps(result))
Code in html:
//I want to use Jquery to decode the json data which from server, and
then put the article titles with href into <DIV id="newest"></div>
<html>
<head>
<script src="jquery.js"></script>
<script>
$(document).ready(function(){
$.getJSON("http://localhost:8080/newest?&jsoncallback=?",
function(data){
// Here, I don't know how to use jquery to dedecode the json data
which from server and put the article title with href in <DIV
id="newest"></div>
//I try to use some ways, But firebug tips "invalid lable"Or "syntax
error".
//I am not familiar with Jquery and json. So, who can help me??
});
});
</script>
</head>
<body>
<div id="newest"></div>
</body>
</html>
I don't know how to use jquery to dedecode the json data which from
server and put the article title with href in <DIV id="newest"></div>
I try to use some ways, But firebug tips "invalid lable"Or "syntax
error".
I am not familiar with Jquery and json. So, who can help me??