human art and other bits

Call in data AJAX style thanks to JQuery

, posted: 24-Apr-2010 07:00

The way AJAX has the ability to load in extra data into a website without reloading the whole web page, has always given me a buzz. Now with the help of jquery .load() page it's become possible for even me to make a page function in that classic AJAX style. The code below is taken from my work on a php twitter app. What I got it to do was, expand tweets that are replies when clicked. It passes the ID of the Tweet to fetch when it calls the getTweet.php file. Over view of the code below. Line 20: has a Div with the id of the Tweet that was replied too. There also is the onclick function that calls the getTweet function when clicked. Line7: Is the GetTweet script. Line9-11 is just an alert if the file requested fails. Line8: Does all the work, It gets the id of the div that was clicked and passes it when loading the file to the file getTweet.php the code To get code, visit here. Thanks to Regs for the help.


Other related posts:
EASEUS Todo Backup – my favourite backup software
Jolicloud on the netbook
A couple of new things on my EeePC 1001HA

Comment by chiefie, on 24-Apr-2010 19:58

Yup. It's great for doing AJAX driven on-demand content loading. I've recently implemented something like this too.

Though if you have your content from another site/domain, just be aware that there may be a chance of breaching XSS and some browsers may not like XSS.

Author's note by hellonearthisman, on 2-May-2010 05:23

Thanks Chiefie, I didn't encounter that as I was not requesting a file outside my domain, so it didn't break. Someone people on Stack Overflow also noticed this that with Javascript, and like you said it's to help prevent xss (cross site scripting). They have posted a few solutions this on Stack Overflow

Add a comment

Please note: comments that are inappropriate or promotional in nature will be deleted. E-mail addresses are not displayed, but you must enter a valid e-mail address to confirm your comments.

Are you a registered Geekzone user? Login to have the fields below automatically filled in for you and to enable links in comments. If you have (or qualify to have) a Geekzone Blog then your comment will be automatically confirmed and placed in the moderation queue for the blog owner's approval.

Your name:

Your e-mail:

Your webpage:

hellonearthisman's profile

Brett Cooper
New Zealand

Stone artist with a digital understanding. 1st computer was a c=64