stirman
Joined: 05 Sep 2006 Posts: 1
|
| Posted: Tue Sep 05, 2006 - 5:33 pm Post subject: Writing to a remote database |
|
|
Heya, glad to have found this community and I'm excited about writing my first widget.
I am the creator of ohdontforget.com, and thought building an ohdontforget widget would be a great widget learning project for me.
Ideally, I would like to write directly to the odf online db, from the widget.. is this even possible?
If not, I guess the second best option would be to post to the odf online form, which also may prove challenging as odf is a Rails app and I'm not sure the ugly url's with variables will play nice with my app.
Any help or direction is much appreciated. I have built out the widget up to the point where I am ready to actually submit real data.
Thanks! Glad to have found this place...
-stirman |
|
filipp
Joined: 16 Apr 2006 Posts: 24
|
| Posted: Sun Oct 01, 2006 - 5:24 pm Post subject: |
|
|
I think the easiest would be to send in a post request:
function sendSomething ()
{
var req = new XMLHttpRequest ();
req.open ('post', 'http://myserverside.script', false);
req.setRequestHeader ('Content-Type','application/x-www-form-urlencoded');
req.send ('var1=foo&var2=bar');
alert (req.responseText);
}
Notice I'm sending 'false' as the synchro parameter which means ths script won't continue until it's got a reply from the server. This is good for testing, but not so for users. You can send any number of vairables. The server response will be sent to console.log |
|