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>

2 Answers 2

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?

Sign up to request clarification or add additional context in comments.

Comments

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?

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.