![](/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.