5

How can I make that script pass $('#result').html(search); that search to php file, so that I can use it later on to make an MySQL connection?

I've got it connected to php file: $('#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>
Yang
  • 8,580
  • 8
  • 33
  • 58
user2128056
  • 111
  • 1
  • 6

2 Answers2

0

Looks like the results are generated in class.search.php and then loaded into #result by jQuery. When class.search.php processes why not just put the results in a $_SESSION until you're ready to use them?

Phillip Berger
  • 2,317
  • 1
  • 11
  • 30
0

If you are just trying to pass data from Jquery to php and vice verse, probably Ajax and Json would be a best way to get data accross. Please look at this previous post. How to pass jQuery variables to PHP variable?

Community
  • 1
  • 1