0

OK so I set up a new server (droplet on DigitalOcean).

Say the url is 55.55.555.555 and my file file5.php was added to folder /home/user5 using WinSCP

What would the URL in my AJAX request look like, letter for letter?

Right now, for testing on my local EasyPHP server, it looks like this:

request.open( "POST" , "file5.php" , true );
Ben
  • 8,894
  • 7
  • 44
  • 80
TVG
  • 259
  • 3
  • 8
  • Show what you tried so far. – William Francis Gomes Jul 23 '15 at 13:24
  • It should work the same as your local test – Hakim Jul 23 '15 at 13:26
  • Can you access the file5.php using any url? – William Francis Gomes Jul 23 '15 at 13:27
  • request.open("POST","http://55.55.555.555/home/user5/file5.php",true); – TVG Jul 23 '15 at 13:27
  • @WilliamFrancisGomes what do you mean by that? I can find it in the directory using SSH, if that's what you mean. Wouldn't the browser need to know which server to send the request to? – TVG Jul 23 '15 at 13:32
  • I meant that can you access that file using url like http://55.55.555.555/file5.php ? – William Francis Gomes Jul 23 '15 at 13:35
  • @WilliamFrancisGomes just tried that! got this message: XMLHttpRequest cannot load http://55.55.555.555/file5.php. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access. The response had HTTP status code 404. – TVG Jul 23 '15 at 13:40
  • First make a file which only echo "Hello world!" and upload it in the same directory as file5.php. Then try to access that uploaded file using your web browser. If you succeed then let me know the link. – William Francis Gomes Jul 23 '15 at 13:43
  • @TVG you are not allowed to make cross origin domain request without adding proper headers to your request. Exp: http://stackoverflow.com/questions/25520085/how-to-get-http-request-origin-in-php P.S: 255 is the max you can go in an ipv4 ip block, just FYI ;) – Twisted1919 Jul 23 '15 at 13:48
  • @Twisted1919 ahhh of course. So my request header should be header("Access-Control-Allow-Origin: " . $_SERVER[55.55.555.555'] . "")? and yeah 55.55.555.555 is obviously not the real URL haha, just using it as an example – TVG Jul 23 '15 at 13:53
  • @TVG -You could as well use * as the header value, will allow everything, which will make things easier for testing. – Twisted1919 Jul 23 '15 at 13:59
  • @Twisted1919 the following have not worked: request.setRequestHeader("*","application/x-www-form-urlencoded"); and request.setRequestHeader("http://55.55.555.555","application/x-www-form-urlencoded"); and request.setRequestHeader("Access-Control-Allow-Origin: http://55.55.555.555","application/x-www-form-urlencoded"); and request.setRequestHeader("Access-Control-Allow-Origin: http://55.55.555.555",""); ..... – TVG Jul 23 '15 at 14:03
  • @Twisted1919 should I be adjusting my Javascript files, or my PHP files? My understanding is that my front end isn't even able to access my server at all – TVG Jul 23 '15 at 14:20

0 Answers0