Mostly, rest api url' s like:
/api/student:id/notes
I create a rest api and my urls like above. But I dont know how to add parameter before notes.
$.ajax({
url : "api/v1/student/notes",
data : { "id" : uid },
type : "get",
headers : { "Authorization" : api_key },
dataType : "json",
success : function(response) {
console.log(response);
}
});
When I call like this, the url seems /api/student/notes?id=5
. How can Iadd id parameter between student and notes?
Example url: http://www.sitepoint.com/best-practices-rest-api-scratch-introduction/
AFAIK, jQuery does not offer a neat API for injecting resource URI fragments like Angular's $resource
. You'll have to build the URL yourself. Something like
$.ajax({
url: 'api/v1/students/' + encodeURIComponent(uid) + '/notes',
// and so on, no "data" required.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.