Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 536637
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T09:50:34+00:00 2026-05-13T09:50:34+00:00

When I use ajax, I have to use mysql_query again to get information in

  • 0

When I use ajax, I have to use mysql_query again to get information in that file which is for ajax. Can I do action without mysql_query like with include();?
Ask if you don’t understand, because I guess I asked not very properly.

edited: When I try to reach ajax file, in that file I have to retrieve member information again. So, my question is, is it possible to avoid that?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T09:50:35+00:00Added an answer on May 13, 2026 at 9:50 am

    Use a combination of content negotiation and caching, e.g

    Controller
        Action
            // check if query is cached
            if(!Cache->hasSaved(Query))
                Result = Query->run
                Cache->save(Result)
            else
                Result = Cache->getSaved(Query)
    
            // check if Request was done via Ajax
            if(Request->isAjax)
                View->disableLayout
                View->set(JSON->encode(Result))
            else
                View->set(Result)
    

    Like Ignacio explained, each requests to the server is isolated. PHP has a shared nothing architecture, so the only thing you can do to prevent the query from running again is to cache it. Content negotiation just helps to use the same query and return it on the depending request context, so you dont have a Controller Action for Ajax and one for regular calls.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have many forms that use AJAX (w/ jQuery) for validation and data submission.
Can I have good example or code about how to use Ajax Datepicker in
While debugging jQuery apps that use AJAX, I often have the need to see
I have a website that makes heavy use of AJAX. There is an almost
I have written a web app in PHP which makes use of Ajax requests
I have a webforms page that makes quite extensive use of AJAX. There are
I have an asp.net user control on which I want to use jquery ajax.
I have a WCF based service that I use to expose AJAX functionality. Sometimes
I have a small jQuery plugin that I use for form AJAX validation. There
I have a simple div that i use to trigger an ajax post. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.