I have used curl to fetch a webpage. There are links on this page. On the curl fetched page when I click a link I want JQuery to execute a curl script to fetch that link. I have the following code..
This is my index page which fetches example.com via curl and echos it out.
<html>
<head>
<title>Public</title>
<script type="text/javascript" src="click.js"></script>;
</head>
<?php
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, 'www.example.com');
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
$curl_response = curl_exec($ch);
curl_close($ch);
echo $curl_response;
?>
click.js I'm targeting the tag so when any link is clicked this will execute. Will this work?
$(".a").click(function(){
$.getScript("curllink.php");
});
This is the script I want the js to run when a link with the tag curllink.php
<?php
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, 'WHAT DO I PUT HERE?');
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
$curl_response = curl_exec($ch);
curl_close($ch);
echo $curl_response;
?>
Please could you check over this and fix any errors I have made. Thanks
<a>tag, 2. whats$.getScript()? 3. are the content within your website? or a thirdparty website?