Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I have a php script(example.php), which is using multiple cURL to load 20 pages at the same time.. for example google.com, ebay.com .. It takes 5 seconds to load example.php and its quite a lot so.. I also have a simple html file(index.html) with short loadtime . And what I want is : having a script included in index.html which gets element by id from pages loaded in example.php And why? I want to have a page with fast load time(index.html), which could get elements from sites like google.com, ebay.com, facebook.com (which are actually loaded in example.php on the background) ... Example.php and index.html are on the same domain, so there should be no problem with that..
Accessing content from external websites can't be done easily with Javascript due to the Same Origin Policy. You can however display the entire page in one go by use of an iframe.
You can circumnavigate this with a variety of methods using the server as neatly provided here.
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 1 year ago.
Improve this question
I explain my problem to you:
When I do PHP curls on some site or want to display the source code of the page element is missing a lot. I think some part is called by a script or something. Could someone help me view the entire code with Curl PHP.
To duplicate my problem go to Facebook or LinkedIn and right click on the page and "View the source code of the page", in this you don't see all the page content but when for example you right click and "inspect an element" You can.
Thank you in advance
CURL can't do this. It's not designed to render HTML or execute JavaScript.
A lot of the content on Facebook, LinkedIn, Twitter and many other pages is loaded through different ways. (like fetch()-requests or WebSocket-Events)
Some nodes you can see in the inspector are not part of the original document (which you are viewing with "view source" or curl downloads). What you see on the inspector is everything currently held in memory, which was partially (or completely) created with a scripting language.
This is basically done to
reduce the load on servers as it doesn't have to generate the whole page on every request
reduce traffic on clients and servers (no need to reload the header-data and/or scripts over and over again)
If you need data from a rendered site, you should either check if the website provides an API which gives you the data you are looking for or use one of the cli-rendering-engines from this answer.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 5 years ago.
Improve this question
I am working on a site that calls various different pages and forms through ajax. To save page loading times I'm trying to only load the .js files that I need for each page or form, but during development this causes several issues and errors, like events or elements having to be referenced through $(document). Also, Jquery now throws a deprecation warning for loading inline js through ajax.
I know I can call external scripts through jquery's .getScript() function, and will be able to resolve all errors, but I'm wondering if it wouldn't just be a whole lot easier to include all the required script files in the main header (or footer).
What approach is more efficient in terms of work flow vs user experience? Load all the site js initially, or load scripts dynamically as needed? (In this case, total size of extraneous js files is approx 50kb)
I recommend you load dynamically when you need it, and put each js file in each file you gonna load, and forget load() wich is actually deprecated, use $.ajax() syntax.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I want my users to be able to view content on my website, and when they see content they like (My website randomly generates content using JQuery.load() ), I would like them to be able to store it onto a personal page that they have to log in to, to see.
My page loads content with the line:
$(".resultContent").load(skillList[skillChoice]);
The variable "SkillList" is assigned "skills.html #id"
the '#id' part is identifying a <div>, and that's the part I want to be stored, and I want the user to be able to store multiple parts of the page skills.html on their personal page.
This sounds fairly complex, but I was wondering if it's doable, if so, what language(s) would I need to use?
You will need to save those html snippet on the server, mostly likely in a database. This can be done by client-side javascript, an ajax POST. The server side can use any language.
Since you are saving some html on the server and will load that in a page. The server side must sanitize the html snippets for security.
When the html snippet is saved, the server needs to know who sends the request. That is the user needs to log in before or when s/he saves the content for later use.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
First of all sorry for my English. I'm working on a little website (I'm learning web design and PHP). As you can see in the page index.php, there are three buttons: login, registration (register) and guest. I've three scripts, one for login, one for register and one for guest access to site.
How can I show the script "login.php" or "register.php" or "guest.php", just under the buttons, when I click on the corresponding button?
Here are index.php and css files:
Download
use jQuery http://www.jquery.com makes life soo much easier
$(document).on("click","#login-btn",function(){
$("#div-where-to-load-stuff").load("url/to/login.php");
})
this is very bare bones. there are better ways to do it tho.
http://api.jquery.com/load/
You will have to either use AJAX or an IFRAME to load content asynchronously.
I really like to use the jQuery Forms plugin (in case you are able to use jQuery). Otherwise you have to look into AJAX or iFrame.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
can my page Javascript read same page which itself is loaded? Like other parts of page are dynamically loaded by other provider. I have tried many things, google as well, but now I am in doubt that it is posible. Or it is.
Thank You!
If the page has loaded and the javascript you are running is client-side (which it should be), you should be able to access everything on the page via the document object. I would advise reading about the DOM to familiarise yourself with this.
EDIT: removed link
Server side code (whether written in JavaScript or otherwise) is not capable of determining the final rendering of the page in the user's browser.
You could build the entire page yourself (and you could use a headless browser, like PhantomJS, to do it) but that could give different results to a visitor's as you would have a different set of cookies, a different source IP address, and so on.