-
Notifications
You must be signed in to change notification settings - Fork 1
Browser Console Tests
Quan Li edited this page Jun 18, 2013
·
4 revisions
/*
* /category/{id} GET
*
*/
$.ajax({
url: '/discourse/category/1',
type: 'GET',
async: false,
success: function(data){
console.log(JSON.parse(data));
}
});
/*
* /category POST
*
*/
$.ajax({
url: '/discourse/category',
type: 'POST',
data: {
name: "category1",
color: "777777",
slug: "this is description of category 01"
},
async: false,
success: function(data){
console.log(JSON.parse(data));
}
});
/*
* /category/{id} PUT
*
*/
$.ajax({
url: '/discourse/category/1',
type: 'PUT',
contentType : 'application/json',
data: {
name: "category1",
color: "777777",
slug: "this is description of category 01"
},
async: false,
success: function(data){
console.log(JSON.parse(data));
}
});
/*
* /category/{id} DELETE
*
*/
$.ajax({
url: '/discourse/category/2',
type: 'DELETE',
async: false,
success: function(data){
console.log(JSON.parse(data));
}
});
/*
* /category/{id}/{offset}/{limit} GET
*
*/
$.ajax({
url: '/discourse/category/1/0/2',
type: 'GET',
async: false,
success: function(data){
console.log(JSON.parse(data));
}
});
/*
* /topic/{id} GET
*
*/
$.ajax({
url: '/discourse/topic/1',
type: 'GET',
async: false,
success: function(data){
console.log(JSON.parse(data));
}
});
/*
* /topic POST
*
*/
$.ajax({
url: '/discourse/topic',
type: 'POST',
data: {
title: "topic1",
content_raw: "first speach in topic 1",
category_id: 1,
},
async: false,
success: function(data){
console.log(JSON.parse(data));
}
});
/*
* /topic/{id} PUT
*
*/
$.ajax({
url: '/discourse/topic/2',
type: 'PUT',
contentType : 'application/json',
data: {
title: "topic222",
},
async: false,
success: function(data){
console.log(JSON.parse(data));
}
});
/*
* /topic/{id} DELETE
*
*/
$.ajax({
url: '/discourse/topic/3',
type: 'DELETE',
async: false,
success: function(data){
console.log(JSON.parse(data));
}
});
/*
* /topic/{id}/{offset}/{limit} GET
*
*/
$.ajax({
url: '/discourse/topic/1/0/2',
type: 'GET',
async: false,
success: function(data){
console.log(JSON.parse(data));
}
});
/*
* /post POST
*
*/
$.ajax({
url: '/discourse/post',
type: 'POST',
data: {
raw: "another speach in topic1",
topic_id: 1,
reply_to_post_id: 1,
},
async: false,
success: function(data){
console.log(JSON.parse(data));
}
});
/*
* /post/{id} PUT
*
*/
$.ajax({
url: '/discourse/post/2',
type: 'PUT',
contentType : 'application/json',
data: {
raw: "changed content",
},
async: false,
success: function(data){
console.log(JSON.parse(data));
}
});
/*
* /post/{id} DELETE
*
*/
$.ajax({
url: '/discourse/post/7',
type: 'DELETE',
async: false,
success: function(data){
console.log(JSON.parse(data));
}
});
/*
* /post/{id} GET
*
*/
$.ajax({
url: '/discourse/post/1',
type: 'GET',
async: false,
success: function(data){
console.log(JSON.parse(data));
}
});
/*
* /star/{id} PUT
*
*/
$.ajax({
url: '/discourse/star/1',
type: 'PUT',
contentType : 'application/json',
data: {
starred: 1,
// or use 'starred: 0',
},
async: false,
success: function(data){
console.log(JSON.parse(data));
}
});
/*
* /postAction POST
*
*/
$.ajax({
url: '/discourse/postAction',
type: 'POST',
data: {
post_id: 1,
post_action_type_id: 1,
status: 1
},
async: false,
success: function(data){
console.log(JSON.parse(data));
}
});
/*
* /category/{id}.json GET
*
*/
$.ajax({
url: '/discourse/c/1.json',
type: 'GET',
async: false,
success: function(data){
console.log(JSON.parse(data));
}
});