使用第三方库开发JavaScript API

时间:2023-01-19 13:50:58

I currently want to make my project accessible not only via back-end code (C#, Python, PHP, etc.), so I decided to write an easy and simple JS API, every developer can easily integrate within their website / project. Since the whole thing is a service driven system, most of the stuff runs via RPC encoded as JSON.

我目前想让我的项目不仅可以通过后端代码(C#,Python,PHP等)访问,所以我决定编写一个简单易用的JS API,每个开发人员都可以轻松地集成到他们的网站/项目中。由于整个事情是一个服务驱动的系统,大多数东西通过RPC编码为JSON运行。

My problem is, that if I want to make this API I got the following two options:

我的问题是,如果我想制作这个API,我有以下两个选项:

  1. Writting raw RPC functions from ground up
  2. 从头开始编写原始RPC函数
  3. Using jQuery as third-party library
  4. 使用jQuery作为第三方库

The big problem with option number 2, which is by far the best option, is that I have to say "dear developer, you need to use jQuery to access my API", which is striking me, since I do not want to dictate what ppl should or should not use by restricting their opportunities.

选项2的大问题是迄今为止最好的选择,我必须说“亲爱的开发人员,你需要使用jQuery来访问我的API”,这让我感到惊讶,因为我不想指示什么人们应该或不应该通过限制他们的机会来使用。

Is there a way implementing jQuery's RPC stuff without breaking any other potential JS framework the final developer will use?

有没有一种方法可以实现jQuery的RPC内容而不会破坏最终开发人员将使用的任何其他潜在的JS框架?

1 个解决方案

#1


1  

if you're worried about the conflict between jquery and other libraries, use jQuery.noConflict() and it solves your problem!
more info at : http://docs.jquery.com/Using_jQuery_with_Other_Libraries

如果您担心jquery和其他库之间的冲突,请使用jQuery.noConflict()并解决您的问题!有关更多信息,请访问:http://docs.jquery.com/Using_jQuery_with_Other_Libraries

#1


1  

if you're worried about the conflict between jquery and other libraries, use jQuery.noConflict() and it solves your problem!
more info at : http://docs.jquery.com/Using_jQuery_with_Other_Libraries

如果您担心jquery和其他库之间的冲突,请使用jQuery.noConflict()并解决您的问题!有关更多信息,请访问:http://docs.jquery.com/Using_jQuery_with_Other_Libraries