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

  • Home
  • SEARCH
  • 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 7929593
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T20:08:07+00:00 2026-06-03T20:08:07+00:00

i am sending data to a url using jquery ajax. i want to place

  • 0

i am sending data to a url using jquery ajax. i want to place the absolute url using php $_SERVER. what is the syntax to do this?

this is the file path that goes in the URL

$_SERVER['DOCUMENT_ROOT']."/folder/file_name.php"

this is the function that the file path goes in

$.ajax({
            type: "GET",
            url: "",
            data: 'time='+ visitortimezone,
            success: function(){
                location.reload();
            }
        });

what is the syntax for this?

  • 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-06-03T20:08:08+00:00Added an answer on June 3, 2026 at 8:08 pm

    If you really want to get document root from PHP, you can try something like this:

    HTML: (Place your document root in hidden text field)

    <input type='hidden' name='baseurl' id='baseurl' value='<?php echo  $_SERVER['DOCUMENT_ROOT'];?>'>
    

    jQuery: (Get document root in jQuery from hidden text field)

           $.ajax({
                type: "GET",
                url:  $('#baseurl').text() + "/folder/file_name.php",
                data: 'time='+ visitortimezone,
                success: function(){
                    location.reload();
                }
            });
    

    If you are writing your JavaScript in PHP files, you can also try this:

           $.ajax({
                type: "GET",
                url:  "<?php echo $_SERVER['DOCUMENT_ROOT'] . '/folder/file_name.php';?>",
                data: 'time='+ visitortimezone,
                success: function(){
                    location.reload();
                }
            });
    

    You can also get hostname in JavaScript too:

    document.location.hostname
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm sending a JSON object to PHP using jQuery via $.ajax({ url: myURL, type:
I've got a problem sending a file to a serverside PHP-script using jQuery's ajax
I am sending a json string using JQuery.ajax to a php page where I
I'm sending some data to an external URL using Curl. The server sends me
jQuery.ajax( { url:'http://en.wikipedia.org/wiki/Football', type:'get', dataType:'jsonp', success:function(data){alert(data);}, } i want to read wikipedia page from
I'm sending post data using jquery, but when I retrieve it in asp all
I'm having difficulty parsing some JSON data returned from my server using jQuery.ajax() To
I am using jQuery and PHP to write JSON data to my server. I'm
I am sending a html form using jquery to ajax, When I send the
I am using JQuery 1.5.1. Sending JSON data (encoded using https://github.com/douglascrockford/JSON-js ) to the

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.