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 3501156
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T12:49:26+00:00 2026-05-18T12:49:26+00:00

Hey guys, I’m building an application which requires access to the server time before

  • 0

Hey guys, I’m building an application which requires access to the server time before sending AJAX requests off, the only way to do this is to be able to have a function that requests the time from the server using AJAX, so in my function I have the following code:

$.ajax({
    type:"GET",
    url:"app/time.php", 
        success: function(html){ return html; } });

In itself the code is fine, but as it is, I am unable to gain access to the returned HTML, meaning the data is useless to me. I’ve tried sending the data to another function, and even back on the same function, and it simply adds complexity that I don’t think is needed. I’ve also tried setting the value of the HTML to another variable and then using, but this doesn’t work outside of the function.

So I’m asking if there is an easy way to have access to the returned “html” variable from the AJAX request so I can set variables on the page equal to the function?

  • 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-18T12:49:26+00:00Added an answer on May 18, 2026 at 12:49 pm

    Do it like this :

     function getTime() {
    
           $.ajax({
            type:"GET",
            url:"app/time.php", 
                success: function(html){ setTime(html); } });
        }
    
        function setTime(time){
        //do what ever you want with time
        }
    

    when ever you call time getTime() an ajax called will be made and the function setTime() will be called, and will get time through its argument.

    or you can do it like this

    function getTime() {

       $.ajax({
        type:"GET",
        url:"app/time.php", 
            success: function(time){ // do what ever with time ; } });
    }
    

    I think this way its easier but if you have a long function then the previous one is cleaner I think.

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

Sidebar

Related Questions

Hey guys i wrote a quick test. I want delete to call deleteMe which
Hey guys. I'm trying to configure TFS2010 on a home server. I want to
Hey guys, first time using stackoverflow. can you guys help me debug? Heres the
Hey guys, I'm using GWT for a data-driven web application, and I'm having issues
Hey guys.. I am writing a Windows application in C# that minifies CSS files
hey guys, i'm getting an exception on the following inner exception: {Value cannot be
Hey, I've been developing an application in the windows console with Java, and want
Hey all. Newbie question time. I'm trying to setup JMXQuery to connect to my
Hey guys, I want to ask if there is an equivalent to the @@DBTS
Hey guys, I'm researching something for a friend of mine who's involved in road

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.