Are you setting the content type. Guessing .NET here so posting basic idea:
public class Handler : IHttpHandler {
public void ProcessRequest (HttpContext context) {
context.Response.ContentType = "text/javascript";
context.Response.Write("alert('hello world');");
}
}