1. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2012
    Rep Power

    Combining Ajax call with standard php?


    I'm using jQuery ajax to fetch results "as-you-type" in a textfield.

    But in the first place when the user visits the page, all the data should be there.. without the user having to type some letters first..

    Do i do this with a normal php call at the top of the page?
    Or do i also use .ajax to load all the data when the page loads.

    Not quite sure how to combine the two.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Dec 2004
    Rep Power
    search for jquery autocomplete. Depending on where/how the values come from, you can query a page to get "appropriate" result or load up all the available options on page load
  4. #3
  5. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Rep Power

    you can do both.

    Putting the data into the initial document means that the visitor will see it even without JavaScript (assuming your page still works then). And some people may prefer a fully loaded page over a half-rendered one with an Ajax spinner.

    On the other hand, when you do everything with Ajax, you don't need redundant code.

    So it's a matter of preferences.
    The 6 worst sins of security ē How to (properly) access a MySQL database with PHP

    Why canít I use certain words like "drop" as part of my Security Question answers?
    There are certain words used by hackers to try to gain access to systems and manipulate data; therefore, the following words are restricted: "select," "delete," "update," "insert," "drop" and "null".

IMN logo majestic logo threadwatch logo seochat tools logo