0

SOURCE SITE: I have a page on a site that generates some HTML - no <head> or <body> tags, just <p> etc. Let's say the URL is here:
http://example.com/warnings-generator.php

TARGET SITE: I'm currently inserting the contents of the above page into my page. Let's say that page is here:
http://example.com/mywarningpage/index.php

EXAMPLE: For this purpose, it looks something like this:
<p>Some text here. Maybe a <a href="">link</a>.</p><p>Multiple paras</p>

What I want to do is to use javascript to grab the contents of the generator.php and update the contents on just that part of the index.php.

I assume I'll need to put the content in a div to make it easier and give that div an id. So let's say when the page loads, that part of the HTML looks like this:
<div id="warnings"><p>Some text here. Maybe a <a href="">link</a>.</p><p>Multiple paras</p></div>

I want to refresh that every, say, 60 seconds.

(I apologize if this has been asked before, but in my searching, I wasn't able to find it.)

  • 1
    Welcome to SO. Please read [What topics can I ask about](http://stackoverflow.com/help/on-topic) and [How to ask a good question](http://stackoverflow.com/help/how-to-ask) and [The perfect question](http://codeblog.jonskeet.uk/2010/08/29/writing-the-perfect-question/). SO is **not a free coding or tutorial service**! You have to show that you've put some efford into solving your own problem. – icecub Jul 08 '17 at 04:50
  • 1
    That being said: What you want is called _website scraping_. You'll need to make an Ajax request towards the target website and filter through the result in order to get the part you want out of it. Try it yourself and if you encounter any specific problem with your code, feel free to create a proper question again and we'll be more than happy to help you out. Good luck! – icecub Jul 08 '17 at 04:57
  • 1
    The answer to this question should get you started: https://stackoverflow.com/questions/6375461/get-html-code-using-javascript-with-a-url – icecub Jul 08 '17 at 04:58
  • Thank you. I did search using various terms, but never stumbled across anything that led me in the right direction. Thank you for doing that. I really do appreciate it! (I definitely wasn't trying to get someone to code me an answer; I just couldn't figure out even how to get started. I don't speak js, so it's harder to find specific answers when I try and hack something together. hehe) – Isaac Eiland-Hall Jul 08 '17 at 06:02
  • Well, like my teacher used to say: _Don't dive into the ocean without getting your swimming certificates first. You'll simply drown._ Most of us start coding because we've encountered a specific problem and want it solved. But just like with any language: You can't have a full conversation in it without learning it first. So step back. Learn the basics. It may not solve your problem right now, but it will help you solve most problems in the future. – icecub Jul 08 '17 at 06:39

0 Answers0