Ryan,
>From the browser side, this is exactly what jQuery.get() and
jQuery.getJSON() do. Both are shortcuts for jQuery.ajax(). The only
difference between them is that get() allows you to retrieve any datatype
(XML,JSON,etc.) while getJSON() retrieves JSON encoded text files and
automagically converts them into a JavaScript Object.
The server side is already handled by node's express module, which allows
you to specify the MIME-type of the data it sends back in response to an
HTTP GET request.
So, from the client-side, you'd:
$.get('/url-to-text-file',function(data,textStatus,jqXHT){
if(!textStatus.match(/^200/)){
// do something with the error
return;
}
// do something with the data
},'text');
See the docs for express (http://expressjs.com/) for how to specify the
MIME type of returned data.
One thing to keep in mind client-side is that all Ajax calls are limited by
the "same origin" policy, where you can only retrieve resources from the
same domain/host/port combination as the requesting page. There are ways
around this restriction which a search for "JavaScript same origin" will
reveal.
All best.
/rr
--
--
Job Board: http://jobs.nodejs.org/
Posting guidelines:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en
---
You received this message because you are subscribed to the Google Groups
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.