如何让该脚本通过 $('#result')。html(search); 搜索到php文件,以便我以后可以使用它来建立MySQL连接?
我已将它连接到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>
答案 0 :(得分:0)
看起来结果是在class.search.php
中生成的,然后由jQuery加载到#result
。在class.search.php
处理时,为什么不将结果放在$_SESSION
中,直到您准备好使用它们为止?
答案 1 :(得分:0)
如果您只是想将数据从Jquery传递到php而反之亦然,那么Ajax和Json可能是获取数据的最佳方式。请看这篇上一篇文章。 How to pass jQuery variables to PHP variable?