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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T15:27:47+00:00 2026-05-28T15:27:47+00:00

I am developing an HTML/Javascript/JQuery page retrieving a JSON returned by a PHP script:

  • 0

I am developing an HTML/Javascript/JQuery page retrieving a JSON returned by a PHP script:

$.ajax({
url: "data.php",
    dataType: 'json',
success: function(rate) {
        var retr = JSON.stringify(rate, null, 2);
        $("#data").text(retr);
},
    error: function(request,error) {
        alert(request.statusText);
    }
});

When I view the HTML page from my local PC, the Ajax returns the PHP script code rather than the JSON the PHP code should generate. Somehow, it makes sense since it does not go through a PHP engine.

I have tried replacing url: "data.php" with url: "http://www.mysite.com/data.php" or url: "www.mysite.com/data.php", but it does not work.

I would like to avoid uploading my page on a server to test it. I would like to be able to invoke the PHP on my PHP server directly from my local PC. Is this possible?

  • 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-28T15:27:48+00:00Added an answer on May 28, 2026 at 3:27 pm

    you will have to upload the page on the server, otherwise you will be restricted by CORS

    add the following line in your php script

    <?php
    header('Access-Control-Allow-Origin: *');
    echo json_encode("hello");
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm developing a JavaScript API service. Main html page looks like this: <html> <head>
I am developing a web application that uses JQuery AJAX and PHP to upload
I am developing a web-based javascript/html application with a sister firefox-extension. The application's page-javascript
I'm new to jQuery and PHP. I'm developing a web page to display a
Hi I'm developing an application with HTML and javascript (jquery), the HTML has a
I am new to both javascript and jQuery. I am developing a page in
Im developing a javascript/php/ajax application and have stumbled across some problems. Im confident at
I'm developing a small app designed to embed HTML + JavaScript (JavaScript manages the
I'm developing a Web App that uses JavaScript + JQuery on the client side
Basically I have a php script located on a sever that generates a JSON

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.