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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T21:01:09+00:00 2026-06-08T21:01:09+00:00

I am having problems with this topic: Access-Control-Allow-Origin. I read about it and I

  • 0

I am having problems with this topic: Access-Control-Allow-Origin.

I read about it and I found that is possible to get response using php, here

But I don’t know how to adapt that code to javascript, I still have the same problem.

I tried this in javascript:

var url ='http://localhost:8080/com.webserver/rest/manage/order?parameter=parameter';
req=Ajax("getResponse.php/?" + url)
  if (req.status=200)
alert("hi");

And on php file:

<?php
echo file_get_contents($_GET['url']); 
?>

And nothing happends. I tried with ajax, something like:

$.ajax({
          url: "http://localhost:8080/com.webserver/rest/manage/order?parameter=parameter",
          async: false,
          dataType: 'html',
          success: function (text) {
            alert(text);
          }
        });

But always same problem….

I read lot of people on internet having the same problem, but no one get a response. I just found 2 ways, using chrome and one option but just recomended for developers and adding headers on server but I don’t know where to add them. I am using apache tomcat catalina for that localhost. I have 2 servers, webpage (in xampp) and rest (in tomcat)

  • 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-08T21:01:11+00:00Added an answer on June 8, 2026 at 9:01 pm

    Change

    req=Ajax("getResponse.php/?" + url)

    to

    req=Ajax("getResponse.php/?url=" + url)

    Bare in mind this is insecure, i could pass anything into the url parameter and your php scripts would use it. Allowing people to read files from your local system as well as get your php script to download malicious files from elsewhere

    Edit:

    To best way to secure it is to use an actions list, this means that the user never see’s the url and can only modify an action word. for example

    req=Ajax("getResponse.php/?do=getOrders")

    then in php

    $actions = array();
    $actions['getOrders'] = "http://localhost:8080/com.webserver/rest/manage/order?parameter=parameter";
    
    if(array_key_exists($_GET['do'], $actions))
     echo file_get_contents($actions[$_GET['do']]);
    

    Usually you’d want to do more that just translate an action to a url, you may want to pass additional parameters. In this case you could use a switch or a bunch of IF’s to check if $_GET[‘do’] is equal to something and then process it. but it would take hours to give an example of every possible implementation method, so you may want to use google.

    Please note: whilst this method is suggest adds 100x more security to your script, its not infallable, especially if you start passing through parameters from users too. Once again use google.

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

Sidebar

Related Questions

Having read some postings here about this topic, I realize that there are quite
I'm having problems reading this one JPEG file using ImageIO.read(File file) - it throws
I am having some problems figuring out this issue. I have a server that
I am having some troubles with my script.. when I access http://www.domain.com/this-is-a-topic I want
Greetings, I've read some threads about this topic, but actually I was unable to
I have read through Scott Hanselman's post on this topic. I found another article
I'm having problems with this site I am building. I need a fixed width
I've been having problems with this code I had spent the last 3 hours
I am having problems posting this multi checkbox data with ajax. <?php foreach($_SESSION['contacts'] as
I am having problems with this code: <?php $new_value = 'testing'; $con = mysql_connect(localhost,user,pass);

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.