好的,我正在我的项目中使用 RESTful 后端,并通过 jquery 提交数据。
我必须说 werkzeug 调试器非常适合调试,特别是当你像我一样是一个糟糕的 Python 程序员时。您故意在要调查的地方抛出异常,并使用调试器呈现的 html 检查代码和变量。
但是,当您发送 post 请求而不是 get 请求时,如果您在后端代码上抛出异常,当然浏览器将不会呈现响应文本。
考虑到它有javascript和所有东西,我可以使用任何技术来呈现响应文本吗?
我正在尝试不同的事情,例如尝试将响应文本注入弹出窗口,例如:
$.postJSON = function(url, data, callback, error_callback) {
return jQuery.ajax({
'type': 'POST',
'url': url,
'contentType': 'application/json',
'data': JSON.stringify(data),
'dataType': 'json',
'success': callback,
'error': error_callback
});
};
$.postJSON('/the_uri', {'foo': 'bar'},
function(response) {
var a = 0;
},
function(response) {
var html = response.responseText;
var my_window = window.open('', 'mywindow1', 'width=350,height=150');
$(my_window.document).find('html').html(html);
});
});
但这不会很好地处理 javascript。
有人有什么建议吗?