Massassi Forums Logo

This is the static archive of the Massassi Forums. The forums are closed indefinitely. Thanks for all the memories!

You can also download Super Old Archived Message Boards from when Massassi first started.

"View" counts are as of the day the forums were archived, and will no longer increase.

ForumsDiscussion Forum → Javascript HTTP reqeuests
Javascript HTTP reqeuests
2009-08-02, 2:42 PM #1
I'm trying to build a Google gadget using XML/Javascript by following the lessons here. However, I can't seem to figure out a way to send GET and POST requests using Javascript. Is this even possible? Any one else have experience working with Google's APIs?

EDIT: Sorry for the incorrect spelling in the title

2009-08-02, 3:03 PM #2
I don't know about Google's API's but normally you would need to use XMLHTTPRequest.
2009-08-02, 3:05 PM #3
Both jQuery and Prototype javascript libraries make it easier.
2009-08-02, 3:12 PM #4
What Brian said.
Detty. Professional Expert.
Flickr Twitter
2009-08-02, 4:45 PM #5
Thanks, I'll look into those. Any links to good tutorials would also be helpful.

2009-08-02, 5:24 PM #6
With jQuery:

$.get(path,params,function(data){
// data is whatever the response content is
});

post is identical but with $.post

http://docs.jquery.com/Ajax

Honestly, it's a piece of cake, no tutorials required.
Detty. Professional Expert.
Flickr Twitter
2009-08-02, 6:44 PM #7
Like Detty said, it's called AJAX.

I should probably learn jQuery, I've just been using XMLHTTPRequest.

2009-08-03, 5:30 PM #8
I kept getting a 403 error while running my AJAX scripts. After scrounging around I found out that you can only make requests to server scripts in the same domain.

How the hell can I test my scripts on a local computer?

2009-08-03, 5:50 PM #9
Two things to consider:

1) Browsers often (but not always) won't let you execute AJAX requests from the file:// protocol, your local machine needs to be running a web server.

2) See if the server you are making your requests against supports JSONP, it's a simple wrapper around the JSON format that allows you to access data from other domains. JQuery's getJSON method supports this natively.
Detty. Professional Expert.
Flickr Twitter
2009-08-03, 5:58 PM #10
Originally posted by BombayZeus:
How the hell can I test my scripts on a local computer?


setup a virtual machine with a simple web server
"Nulla tenaci invia est via"
2009-08-03, 6:43 PM #11
Yeah you need a web server, obviously. Most popular one is Apache. Lighttpd is another popular one. I use XAMPP which bundles Apache, PHP, and MySQL together in one package.

↑ Up to the top!