![](/img/trans.png)
[英]fetching data from table row and add as a parameter to the URL in ajax call
[英]Rest API Ajax Call Add parameter to URL
通常,其余api网址如下:
/api/student:id/notes
我创建了一个REST API和上面的网址。 但我不知道如何在注释前添加参数。
$.ajax({
url : "api/v1/student/notes",
data : { "id" : uid },
type : "get",
headers : { "Authorization" : api_key },
dataType : "json",
success : function(response) {
console.log(response);
}
});
当我这样打电话时,网址似乎是/api/student/notes?id=5
。 如何在学生和笔记之间添加id参数?
网址示例: http : //www.sitepoint.com/best-practices-rest-api-scratch-introduction/
AFAIK,jQuery没有提供整齐的API来注入资源URI片段,例如Angular的$resource
。 您必须自己构建URL。 就像是
$.ajax({
url: 'api/v1/students/' + encodeURIComponent(uid) + '/notes',
// and so on, no "data" required.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.