jQuery Ajax调用F#吗?

编程入门 行业动态 更新时间:2024-10-08 10:49:18
本文介绍了jQuery Ajax调用F#吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

有什么方法可以使用jQuery调用f#库,而不必将其包装到Web服务方法中?

Is there any way to make a call to an f# library using jQuery without having to wrap it into a web service method?

推荐答案

如注释中所述,您可以将F#转换为JavaScript.这实际上是可行的,因为它可以使用引号(F#代码的高级表示形式).有两个项目可以做到这一点.一个是相当复杂的名为WebSharper的商业项目(也具有其他功能),另一个是开源项目FSharp.Javascript .

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.

如果要避免使用Web服务,还可以编写一个简单的HTTP服务器.这将是一个可以在服务器上运行的独立应用程序,它将直接处理请求.我在最近的在伦敦的谈话中使用HttpListener类进行了此操作.您可以在此处找到示例.

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.

肯定还有其他方法-如果您在ASP.NET应用程序中工作,则可以使用HttpHandler或用F#编写的页面,该页面将直接处理请求.将主要前端作为C#项目可能更容易,但是您可以在F#中编写页面/处理程序,然后在C#中引用或继承它(例如,使用ASP.NET MVC在这里).

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

更多推荐

jQuery Ajax调用F#吗?

本文发布于:2023-10-19 01:54:54,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1506043.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:jQuery   Ajax

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!