0
点赞
收藏
分享

微信扫一扫

Yii2 ActiveController 支持的所有url类型


1. 列表 get

 

wx.request({
url: 'http://localhost:8080/articles',
header: {
'Content-Type':'application/json'
},
method: 'GET',
success:function(res) {
console.log(res.data)
}
})

 

2. 单个 get

 

wx.request({
url: 'http://localhost:8080/articles/1',
header: {
'Content-Type':'application/json'
},
method: 'GET',
success:function(res) {
console.log(res.data)
}
})

3.新增create post

 

wx.request({
url: 'http://localhost:8080/articles',
header: {
'Content-Type': 'application/json'
},
method: 'POST',
data: {
title: "test article",
content: "test cotent",
category_id: 1,
status: 10
},
success: function (res) {
console.log(res.data)
}
})

4. 更新, PUT

 

wx.request({
url: 'http://localhost:8080/articles/8',
header: {
'Content-Type': 'application/json'
},
method: 'PUT',
data: {
title: "modified title",
content: "modified content",
category_id: 1,
status: 10
},
success: function (res) {
console.log(res.data)
}
})

5. 删除 DELETE

 

wx.request({
url: 'http://localhost:8080/articles/9',
header: {
'Content-Type': 'application/json'
},
method: 'DELETE',
data: {
},
success: function (res) {
console.log(res.data)
}
})

6. OPTIONS

 

wx.request({
url: 'http://localhost:8080/articles/1',
header: {
'Content-Type': 'application/json'
},
method: 'OPTIONS',
data: {
},
success: function (res) {
console.log(res)
}
})

 

​​http://www.codeblogbt.com/archives/62134​​

 

举报

相关推荐

0 条评论