I have a javascript function
function calculate() {
var interestRate=4.5;
...
}
I would like the interestRate to come from a cell in a
You may run into trouble with the Same origin policy. Usually, web browsers do not allow AJAX requests to a different domain as a security measure. I was a little suprised that ultraklon's solution works in firefox, so perhaps this has changed in newer browsers. It doesn't seem to work in IE8 though, so if you need to support that browser, read on.
Usually, JSONP is used as a way around the same origin policy, but this is not an option in your case as google docs does not offer data in this format.
Perhaps the best solution would be to proxy the request to google docs via your own server, as suggested in this question. Create a method on you web server that takes a cell (or cell range) as a parameter. Have the server method request the cell data from google docs, then have it return this data to the caller in JSON format.
Once you have the request proxied, you can get it into your javascript code with a bit of ajax, as in ultraklon's answer:
$.get('/google-docs-proxy?cell=B1', function(data) {
alert('data');
});