I need to get an element with a div id from an external web page.
This is the code I tried to work with but it doesn't return anything.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>TEST</title>
<style>
body {
font-size: 12px;
font-family: Arial;
}
</style>
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
</head>
<body>
<b>Output:</b>
<ol id="tablepress-34_wrapper"></ol>
<script>
$( "#tablepress-34_wrapper" ).load( "https://mrafiee.net/daily-bonus-digital-communication/" );
</script>
</body>
</html>
For example, I want to get the table showing in that page in another external page. How can I do it ? Thanks
The issue you are facing is due to the CORS policy . A workaround would be to use a proxy service such as https://cors-anywhere.herokuapp.com/ ; For instance the following injects the first div
of the remote site into the body
$('body').load('https://cors-anywhere.herokuapp.com/https://mrafiee.net/daily-bonus-digital-communication/ div')
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.