php/jquery architecture question

Posted on 2011-10-30
Last Modified: 2012-05-12
I have a couple of dropdown selects on the main screen, where users can define their search criteria and submit the search to the database. The result is a multipage table of data which I am showing under my selections. Now, is it possible to submit this form asynchronously and refresh only the table area when the result comes back ? Any examples ? Snippets ?
Question by:Rozamunda
    LVL 19

    Accepted Solution

    there are several ways you could do it.

    the return of the php script will be available in the first argument of the success function of the ajax call.

      url : 'path/to/your/script.php',
      success : function(data){
        // data holds whatever script.php prints
        // so if it's your table already in html form, just set the html of a contianer element
    // or even more simply...

    Open in new window


    Author Comment

    How should I collect all the input data from my dropdowns ?
    LVL 19

    Expert Comment

    you can collect the information from you form elements normally, or by using the val() method:


    from there, you can pass variables with the 'data' property of the .ajax argument parameter object, and specify the method (get or post) with the 'type' property:
      url : path/to/your/script.php',
      data : {
        some_value : $('#my-select').val()
      type : 'POST',
      success : function(data){
    // the php script would get $_POST['some_value'] set to the value of your dropdown

    Open in new window


    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    Single record delete with php/ajax 20 33
    Issues with signature 19 25
    simple if statement 3 16
    Page not loading properly 15 22
    OverviewThis article demonstrates a simple search form using AJAX. The purpose of the article is to demonstrate how to use the same code to render a page and javascript (JQuery) and AJAX to make subsequent calls to refine the results. The princip…
    There are a couple ways to attach a JavaScript function to dynamically created elements. You can make a new script for each element as it’s created or you can use delegation. Delegation allows a single script that is added at page creation to mat…
    Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
    The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now