JavaScript REST 客户端库 [英] JavaScript REST client Library

查看:40
本文介绍了JavaScript REST 客户端库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有允许我执行所有 REST 操作的 JavaScript 库,例如(GETPOSTPUTDELETE over HTTPHTTPS)?

Is there a JavaScript library which allow me to perform all the REST operation like (GET, POST, PUT and DELETE over HTTP or HTTPS)?

推荐答案

您实际上并不需要特定的客户端,对于大多数库来说这相当简单.例如,在 jQuery 中,您可以使用您想要发出的请求类型调用通用的 $.ajax 函数:

You don't really need a specific client, it's fairly simple with most libraries. For example in jQuery you can just call the generic $.ajax function with the type of request you want to make:

$.ajax({
    url: 'http://example.com/',
    type: 'PUT',
    data: 'ID=1&Name=John&Age=10', // or $('#myform').serializeArray()
    success: function() { alert('PUT completed'); }
});

您可以将 PUT 替换为 GET/POST/DELETE 或其他.

You can replace PUT with GET/POST/DELETE or whatever.

这篇关于JavaScript REST 客户端库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆