0

Can anyone tell me what's the best way to test JavaScript code (particularly linking it to a data file e.g. csv or Json) without it being in a server (i.e. from desktop). I'd like to create and test the JS on my machine before deploying it to the work intranet. Not had much experience with running server on laptop so would like to avoid this if possible.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
DataDancer
  • 175
  • 1
  • 2
  • 11
  • Can you share more info on your environment? Are you using ASP.NET, php or something else? How are you testing your website? If it's only about the javascript with some HTML, you can just open a html file in your local browser to test it. – Wouter de Kort Jan 04 '13 at 08:22
  • yes it is simply some HTML with JavaScript and up until now that is what i am doing. everything works fine until i want to call a csv file containing my raw data (for graphing). i am prevented from doing this with the page not coming up. im taken to believe that this is brower security in action that is preventing me – DataDancer Jan 04 '13 at 08:28

2 Answers2

2

Running a webserver on your desktop really is the best solution for this, since ajax calls are not allowed for local files.
You could look into xampp, or just fire up your IIS to run your own webserver. xampp is probably a bit easier if you have no experience with web servers what so ever.

Alternatively, an IDE might provide an ad hoc webserver. Visual studio express for example uses a built in development server that alows you to serve your files, some experience with this IDE is obviously also required.

If all this doesn't work you can always try a sandbox service like http://jsfiddle.net/

A fully fledged and free online IDE to develop/test/deploy your code can be found at Cloud9

Willem D'Haeseleer
  • 19,661
  • 9
  • 66
  • 99
  • great suggestions thanks. immediately the sandbox solution looks the most promising but longer term i suspect that i will need to brush up on my IIS jargon. any nice resources that you may suggest would be helpful? – DataDancer Jan 04 '13 at 08:33
1

You might be running into this problem. Basically certain security policies don't allow you to fetch local files . This question talks a bit about how to deal with Same Origin Policy things. A google serach of "Same Origin Policy"+(browser name) might help out too.

This article gives workarounds for most major browsers.

Community
  • 1
  • 1
rtpg
  • 2,419
  • 1
  • 18
  • 31