如何讓該腳本通過$('#result')。html(search);搜索到php文件,以便我可以稍後使用它來建立MySQL連接?jQuery:將變量傳遞給php
我把它連接到了php文件:$('#result')。load('class.search.php');
$('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: function(search) {
$('#result').load('class.search.php');
}
});
new App.Router();
Backbone.history.start();
})();
-
<form name="input" action="" method="get">
Search: <input type="text" name="search">
<input type="submit" value="Submit">
<div id="result"></div>
</form>