出於某種原因...它沒有從script.php
獲取任何數據,當我提交表單時,似乎存在提交問題。當我點擊提交按鈕。它去search.php?search=wasd
如果我刪除$.post
功能,沒有問題。
$('form').submit(function() {
var form_data = ($(this).serialize());
window.location.hash = form_data.replace('=','/');
return false;
});
(function() {
window.App = {
Models: {},
Collections: {},
Views: {},
Router: {}
};
App.Router = Backbone.Router.extend({
routes: {
'': 'index',
'search/:search': 'search',
'*other': 'default'
},
index: function() {
$(document.body).append("");
},
search: $.post("script.php", function(search) {
$('#result').html(search);
});
});
new App.Router();
Backbone.history.start();
})();
我不知道主幹,但我認爲搜索:預期功能在這裏,所以嘗試包裝郵政編碼的功能.. – 2013-03-06 11:29:49
外觀文件'搜索:$ .post(「script.php」,功能(搜索){ $(' #result')HTML(搜索)。 (''result').html(search); });}' – 2013-03-06 11:32:18
};''應該是'search:function(){$ .post(「script.php」,function(search){0128}您正在將'search'屬性設置爲調用'$ .post()'函數的結果。 – nnnnnn 2013-03-06 11:35:11