开发者

jQuery Ajax call to F#?

I开发者_Python百科s there any way to make a call to an f# library using jQuery without having to wrap it into a web service method?


As mentioned in comments, you could translate F# to JavaScript. This is actually pretty doable, because it can use quotations (a high-level representation of F# code). There are two projects that do this. One is a rather sophisticated commercial project named WebSharper (which has other features too) and the other one is open source project FSharp.Javascript.

If you want to avoid web services, you can also write a simple HTTP server. This would be a standalone application that you can run on your server and it will directly handle requests. I did that using HttpListener class in a recent talk in London. You can find the sample here.

There are definitely other ways - if you're working in ASP.NET application, then you can use HttpHandler or a page written in F# that will just handle the request directly. It is probably easier to have the main front-end as a C# project, but you can write the page/handler in F# and just reference it or inherit from it in C# (example using ASP.NET MVC is here).


You could write a HttpHandler as a wrapper.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜