best way to do cross-site request? |
I am in a chrome extension background page. I want to query my CI app, cross-site for some info. What is the best way to do this?
XMLHttpRequest? $.post? some other way? I tried using $.post("http://localhost/subit_backend/login_daemon.php","action=login", processResponse); but the "$" is not found.
proof that an old dog can learn new tricks
Are you sure you've loaded jquery?
Codeigniter is simply one of the tools you need to learn to be a successful developer. Always add more tools to your coding arsenal!
This article may help you:
Cross-Origin Resource Sharing (CORS) What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
(03-06-2018, 07:29 AM)albertleao Wrote: Are you sure you've loaded jquery? Actually I am not! The main part of the Extension uses jquery. Here is the top of my html file <script type="text/javascript" src="jquery-1.11.1.min.js"></script> <script type="text/javascript" src="jquery-ui-1.11.1.min.js"></script> <script type="text/javascript" src="jquery.appendGrid-1.6.3.js"></script> <script src="popup.js"></script> <script src="background.js"></script> <script type="text/javascript" src="date.js"></script> And background.js is the file where the $.post appears.
proof that an old dog can learn new tricks
(03-06-2018, 08:50 AM)Muthusamy Wrote: @richb201 According to my point of view $.post is a valid JQuery function. Whereas Code: $_POST("http://localhost/subit_backend/login_daemon.php","action=login", processResponse)
I am still at getting the token. When I run the code below I get a whole slew of fields about myself in response.
response= "{ "id": "1109308060260095483xx", "email": "[email protected]", "verified_email": true, "name": "Richard Berns", "given_name": "Richard", "family_name": "Berns", "link": "https://plus.google.com/1109308060260095483xx", "picture": "https://lh4.googleusercontent.com/-tzUZ4ZmxxJM/AAAAAAAAAAI/AAAAAAAAAAA/HDERazJjQtE/photo.jpg", "gender": "male" } " var x = new XMLHttpRequest(); x.addEventListener("load",reqListener); //this callabck means we got the email x.open('GET', 'https://www.googleapis.com/oauth2/v2/userinfo?alt=json&access_token=' + token); x.send(); function reqListener(){ console.log(this.response["email"]); } But I only need the response.email field. I will use this as the key that I send to my CI daemon. How do I access the email field in response? My plan is to build a new XMLHttpRequest() to go over to the CI daemen directly in reqListener(). Any pros or cons?
proof that an old dog can learn new tricks
|
Welcome Guest, Not a member yet? Register Sign In |