This is the scenario :
-User is logged in the remote website (via iframe)
-With that cookie saved the user is able to make a get request and obtain a table
-This table is loaded in a second iframe
Problem : I would like to apply styles to that received information.
The output of the request is a simple html file with a table , I cannot access that file from a server (php for example) , because I have no control over the remote site , and in order to make that request user need to be logged (and as said what I do is load an iframe with the get request response..) .
The only thing that comes to my mind is to parse that response , but without a server-side tool , I do not think this is approachable. Any idea?
Related
My app contains a WebView to load a specific site which I cannot edit. This Site at some point executes a POST-Request via AJAX/JavaScript. I need to get the response body of that AJAX-Request do be able to detect wether the process was successfully finished by the user.
I already tried to use the WebViewClient, but I couldn't manage to retrieve the response body of the POST-Request (eg. by using shouldInterceptRequest).
Is there a way to read the data of the AJAX-Request?
I have a website structured like so :
"Client side" : HTML / CSS / Javascript
"Server side" : PHP
Client side, when a user pushes a button, he's redirected to a page (bold because the click action does not trigger a php script, the redirection itself does with window.open("https://...../, '_self');) that toggles a series of scripts back and forth to get, check, and validate data from various other websites and storing some of them in my DB.
Once this is all done, at the end of my last PHP script i need to redirect my user to the original webpage with a bunch of divs and spans and whatsnot updated with the data retrieved.
Typically at the end i'd have this
header( "Location: $originalURL" );
How should i redirect my user while sending back data to the original webpage all the data i need to update my html elements ?
Through a POST request ?
By doing something similar to this :
header( "Location: $originalURL/?data1:$data1&data2:$data2" ); ?
which i would really much avoid not only for its uglyness or unaesthetical aspect, but most of all for the process to be entirely transparant from the user point of view.
EDIT (to explain the 'flow') :
mywebsite.com/mypage/index.**html**
js click function (window.open(mywebsite.come/mypage/processes/index.php))
series of back and forths between external URLs to get data
last call back to my domain mywebsite.com/mypage/stepX/index.**php**
redirection to mywebsite.com/mypage/index.**html**
mywebsite.com/mypage/index.**html** gets the data from step 5 and updates html elements via its script.js
And i'm stuck at step6.
How does my script.js get all the new data directly with the redirection from my server-side PHP script ?
You shouldn't use header(location:) here because it is only a way to force browsers to brutally get to a page.
You need to use require_once() function which is meant to include a PHP file into another. In that way, you would transform your HTML page into a PHP file and you'll be able to access to variables from the file you required.
Passing an HTML file into PHP file is pretty straightforward, it will allow you to transform your PHP variables into JS variables.
There is an external website A (not mine) which provides a PDF document after filling an HTML form.
Here is the scenario when I do the procedure on site A :
I open my Internet browser on the site A homepage (I will call this
page A1), then a JESSIONID is created into my browser's cookie
I fill the form on a page A2
if the form is correctly filled, i am redirected to a page A3,
from which a link is available to download a PDF file, using url :
A.com/getPdf.jsp
I now want to allow users to dowload this PDF file from my website B, using my own form.
To do so :
step 1 : I am sending the form inputs to website A using PHP cURL.
This step is working successfully, and I got a JSESSIONID reference.
step 2 : then I am opening a window from my website using URL :
A.com/getPdf.jsp
But it does not provide me the needed document as the session state is not maintained between previous steps 1 and 2...
So my question is to know how can I call A.com/getPdf.jsp URL, using the same state (same JESSIONID) than the one I retrieved just before from the cURL request?
Thanks in advance for your suggestions.
Below is the scenario am looking at:
I am remotely loading a js file to the site hello.com.
The js is loaded from jsfoo.com.
I want to set a cookie for the domain jsfoo.com in the users browser when the user the is visiting hello.com?
Is it something possible from within the js file that is loaded or do I have to write a server side logic when loading the js?
The objective is to retarget the user who visited hello.com when the user vists jsfoo.com later.
Update based on the comment below:
Would it possible if js is loaded dynamically? For example if we load the js via a dynamic url like jsfoo.com/getjs.php?js=sample.js. Wouldn't it be possible for the code to set and get the cookies for jsfoo.com via php code?
The JS code is executed under your domain, so you can not set that cookie client-side. This is only possible if the script resource loaded from the other domain sets a cookie for that domain via the HTTP response header.
And you won’t be able to access the cookie of jsfoo.com in hello.com. If you need the existing value, then your script on jsfoo needs to read it when the request to its domain happens, and return the value in a way that JS can read it (f.e. by outputting it as a JS variable.)
I have a page (page1.html) and I want to send an ajax to page2.html (http://m-kermani.github.io/getapp.html) and page2.html has an iframe that made by javascript
I made it by javaScript because I need to send a parameter to the page3
In page1.html I have:
$.get('https://m-kermani.github.io/getapp.html', function (data) {
alert(data);
});
and I just need the iframe content but beacuse it made by JavaScript I can't get it and that did not created! (This is the way JavaScirpt is)
I need to send ajax request and get the iframe content because I need an https domain for some reasons that GitHub.io is!
No I need to know is there anyway I can get the content of the iframe from GitHub page?
Is there any other way I can direly just have GitHub page and give the parameter to it and can get the content of the page3 (not using server side language)?
And suggestion about what can I do?
Sounds like you're trying to circumcent the same-origin policy. Unless the API you're trying to access specifically supports a way to do it (CORS, JSONP, etc), you can't do it. You should read the documentation of the API you're trying to access to see if they support accessing it from the client side.
An Ajax request is just a request for a resource. It just gets whatever the server is going to send. It doesn't automatically render the HTML and fetch dependant resources.
If you want the content of a frame, then you have to request the URL for the frame instead of the URL for the page with the <iframe> tag in it.
(The Same Origin Policy will still apply).