I am trying to scrape a random word from a random word generating website. Through reading other forum posts it seems that jquery load
is the way to go in conjunction with some short PHP. I've created a PHP file called "grabber.php" which contains one line:
<?php echo file_get_contents($_GET['url']); ?>
Then I call this in my javascript like so:
$("#word").load('grabber.php?url=http://watchout4snakes.com/wo4snakes/Random/RandomWord #result')
The tag holding the random word on the external site is result
and the tag which I want my site to hold the data is word
.
For some reason it isn't working at all. It will delete whatever is held in the word
tag header. What am I doing wrong? Thanks!
If it helps, my html code is:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
<link href="main.css" rel="stylesheet" type="text/css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src=timer.js></script>
</head>
<body>
<h1>Hello</h1>
<h2 id="time">The Timer is Here: </h2>
<h2 id="word">Word Goes Here</h2> </body>
</html>