Take the 2-minute tour ×

I would like to test out some interviewees by having them write some javascript that will make requests against my server. I don't want to give them write access to my code base. Javascript runs on the client side, so this should technically be possible. However I know there are browser restrictions that say that the javascript has to come from the server?

I apologize that this is a really dumb question, but how should I proceed?


Ok, so I failed to mention that the entire application is based off sending JSON objects to and from the server.

share|improve this question
add comment

3 Answers

up vote 1 down vote accepted

I think you're thinking of the javascript XMLHttpRequest object itself, in which case, yes the current standard is for browsers to block cross-domain calls. So, you can tell them to pretend they either have a separate proxy script on their own personal domain which will allow them to leap to yours, or to pretend they're building a page directly served from your domain. There's talk of browsers supporting trust certificates or honoring special setups between source and target servers, but nothing universally accepted AFAIK.

Javascript source itself does not need to come from the server, and in fact this is how you can get around this little XMLHttpRequest block by using json. Here's a simple json tutorial I just dug up from Yahoo. But, this calls for your server to provide a json format feed if your server is the intended target.

share|improve this answer
add comment

"there are browser restrictions that say that the javascript has to come from the server"

I'm not aware of any situation where that's the case, only a lack of a console. But...even in those cases there's the address bar and javascript:.

If I misunderstood and you're talking about cross-domain restrictions, then your server needs to support JSONP for the requests so they can make cross-domain calls for data.

share|improve this answer
add comment

You could POST the javascript to your server and then your server can send back some HTML that has the javascript inlined. Sounds like you're trying to set up something is, more or less, a homebrew version of http://jsfiddle.net/; AFAIK, jsfiddle just does a "POST javascript/CSS/HTML and return HTML".

share|improve this answer
add comment

Your Answer


