PHP Classes

XMLHttpRequest

Recommend this page to a friend!

      PHP OAuth Library  >  PHP OAuth Library package blog  >  How to Implement PHP ...  >  All threads  >  XMLHttpRequest  >  (Un) Subscribe thread alerts  
Subject:XMLHttpRequest
Summary:can't make a XMLHttpRequest
Messages:7
Author:Francisco Diego Torrado
Date:2015-01-08 05:21:27
 

  1. XMLHttpRequest   Reply   Report abuse  
Picture of Francisco Diego Torrado Francisco Diego Torrado - 2015-01-08 05:21:27
I'm geting "No 'Access-Control-Allow-Origin' header is present on the requested resource" when accesing login_with_goople.php via XMLHttpRequest
Has a solution, can be avoided?
Thanks

  2. Re: XMLHttpRequest   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2015-01-08 20:49:21 - In reply to message 1 from Francisco Diego Torrado
That seems to happen when you send requests to a different domain or localhost I think.

What is the domain of the AJAX request you are sending?

  3. Re: XMLHttpRequest   Reply   Report abuse  
Picture of Francisco Diego Torrado Francisco Diego Torrado - 2015-01-08 21:16:31 - In reply to message 2 from Manuel Lemos
I send a request to login_with_google.php that's in localhost and your class made a request to https://www.googleapis.com/oauth2/v1/userinfo

  4. Re: XMLHttpRequest   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2015-01-09 00:17:37 - In reply to message 3 from Francisco Diego Torrado
Yes, I guess that AJAX request is sending that header but it shouldn't. Are you using custom JavaScript or some library like jQuery to send the AJAX request?

Try seeing if you can disable that header. Alternatively you can also try this class that does not send that header.

jsclasses.org/package/353-JavaScrip ...

  5. Re: XMLHttpRequest   Reply   Report abuse  
Picture of Francisco Diego Torrado Francisco Diego Torrado - 2015-01-09 08:50:02 - In reply to message 4 from Manuel Lemos
Thanks I'm usign Jquery, but I'm going to test your class

  6. Re: XMLHttpRequest   Reply   Report abuse  
Picture of Francisco Diego Torrado Francisco Diego Torrado - 2015-01-09 16:30:07 - In reply to message 5 from Francisco Diego Torrado
Don't work, the same problem...

  7. Re: XMLHttpRequest   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2015-01-09 20:08:04 - In reply to message 6 from Francisco Diego Torrado
I think that is because you are using it from localhost.

You may want to try creating a new local domain in your machine and configure your Web server to use it as alternative domain name.

If you are using Linux or something similar you can add a new local domain editing the /etc/hosts files changing the localhost a line to look like like this.

127.0.0.1 localhost www.fakedomain.com