编辑:
这是一个使用/echo/html/
jQuery的工作版本$.ajax()
。
$(document).ready(function(){
var $button = $('#createissue');
var test = function(){
$.ajax({
url: '/echo/html/',
type: 'post',
success: show,
data: {
delay: 5,
html: '<table><tr>' +
'<th>summary</th><td>This is a summary for an issue</th>'+
'<th>reporter</th><td>Christopher Robin</th>'+
'<th>assignee</th><td>Jared from Subway</th>'+
'<th>securitylevel</th><td>Hands in the air! Everyone is suspect.</th>'+
'<th>description</th><td>Something descriptive goes here, I suppose.</th>'+
'</tr></table>'
}
});
};
var show = function(table) {
console.log(table);
$(document.body).append(table);
};
$button.click(test);
});
http://jsfiddle.net/userdude/YCecC/1/
我知道我在某个地方有一个,但不幸的是我没有准备好纯 html 版本。
var test = function(){
$.ajax({
url: '/echo/json/',
success: show,
type: 'post',
data: {
delay: 5,
json: JSON.stringify({
summary: 'This is a summary for an issue',
reporter: 'Christopher Robin',
assignee: 'Jared from Subway',
securitylevel: 'Hands in the air! Everyone is suspect.',
description: 'Something descriptive goes here, I suppose.'
})
}
});
};
var show = function(json) {
var $row,
$cell,
rows = {};
$tbody.empty();
for (field in json) {
$row = $tr.clone();
$cell = $td.clone();
$cell.text(field);
$row.append($cell);
$cell = $td.clone();
$cell.text(json[field]);
$row.append($cell);
rows[field] = $row;
}
$tbody.append(
rows.summary,
rows.securitylevel,
rows.reporter,
rows.assignee,
rows.description
);
$table.append($tbody);
$(document.body).append($table);
};
http://jsfiddle.net/userdude/YCecC/