You get the file parsed. I presumed that was what was asked. Why would you
even want it in text form? And if you DO want it in text form then you can
always convert the resulting object into json again.

In your json file you write:
var some_global_object = {<json data>}

.. then in your code of the callback you can simply reference that object
like you normally would.

AND in case you want to simply parse json data then jQuery is your friend.
Nothing simpler than $.getJSON('ajax/test.json', function(data) { do
something with data });

Personally I see no reason why you would not want to use jquery for this,
since you will probably have very good use for jquery in other parts of
your application as well.


On Thu, Aug 1, 2013 at 11:29 AM, Arnout Kazemier <[email protected]> wrote:

> Please, do tell us how you imagine that to work? How would you get the
> contents of pure JSON file
> when you load in your browser through a external script tag.
>
> On Thursday, August 1, 2013 at 11:14 AM, 
> [email protected]:
>
> Use this instead:
>         var oHead = document.getElementsByTagName('HEAD').item(0);
> var oScript= document.createElement("script");
> oScript.type = "text/javascript";
> oScript.src="http://domain.com/jsonfile.json";;
> oScript.onload = function(){
> alert("Done");
> }
> oHead.appendChild( oScript);
>
> On Wednesday, July 31, 2013 10:42:03 PM UTC+2, ryandesign wrote:
>
> On Jul 31, 2013, at 11:56, Michael Ryan wrote:
>
> >> I know how to use XMLHttpRequest and have already written a loadFile
> function using it. But that's only necessary when running in a browser. I
> have found XMLHttpRequest implementations for node in npm which I could
> include, but all I really want when running in node is for loadFile to load
> the file from the local filesystem using fs.readSync or equivalent.
> >
> > So, why not use fs.readSync?
>
> In node, I probably will.
>
> In the browser, there is no fs module and indeed no filesystem. The
> compatibility modules for fs that I've found use the new HTML5 local
> storage, which is not what I'm after.
>
>
>  --
> --
> 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.
>
>
>
>
>  --
> --
> 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 a topic in the
> Google Groups "nodejs" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/nodejs/Vi8gCST1PSk/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> [email protected].
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 
Med vänliga hälsningar / Best regards

Martin K. Schröder
Försäljning, Säkra Dörren AB
[email protected]
Direkt: +46 8 500 91 997
Mobil: +46 733 38 76 94

FX Säkra Dörren AB
Org nr: 556882-8544 | VAT: SE556882854401
Postadress: Box 55598, 10204, Stockholm
Dörrar: http://svenskasakerhetsdorrar.se
Butiken: http://sakradorren.se

-- 
-- 
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.


Reply via email to