我在Ember.js中爲來自Tornado服務器的搜索結果編寫了搜索操作。現在的問題是,當搜索沒有找到任何結果我提出用tornado.web.HTTPError(statuscode)
錯誤:我怎樣才能得到在燼js行動龍捲風錯誤響應?
Server.py:
=========
if not rows:
raise tornado.web.HTTPError(400)
我試圖處理錯誤在我App.js文件中像這樣:
App.js:
========
search: function() {
// the current value of the text field
var query = this.get('query');
data = $.ajax({
dataType: "json",
url: "/search?query=" + query,
async: false}).error(function(response) {
alert(response.responseText);
}).responseJSON;
在上面代碼當Tornado發生錯誤時,執行.error(response)
,但responseText
爲空。
如何捕獲錯誤並重定向到錯誤頁面?
是錯誤頁面的一個餘燼路由? – thecodejack
它是餘燼路線 –