Outline ·
[ Standard ] ·
Linear+
How to grab html of a given link without having, CORS issue
TSGrammar Police
|
Dec 31 2018, 10:58 AM, updated 6y ago
|
|
I tried using jquery CODE $.ajax({ url: 'your-url', success: function(data) { alert(data); } });
but it wont work as the website is not on my domain hence web security blocked that. error code in chrome : Access to XMLHttpRequest at 'https://.xxx' from origin 'null' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
|
|
|
|
eek-1
|
Jan 2 2019, 12:59 AM
|
|
Maybe curl at your server side and then send out to your ajax?
|
|
|
|
TSGrammar Police
|
Jan 2 2019, 03:59 PM
|
|
QUOTE(eek-1 @ Jan 2 2019, 12:59 AM) Maybe curl at your server side and then send out to your ajax? i dont have a server just me and my local machine. This post has been edited by Grammar Police: Jan 2 2019, 05:14 PM
|
|
|
|
bumpo
|
Jan 2 2019, 06:41 PM
|
|
there is simply no way to do it with ajax call. browser will specifically blocks it as part of security, although if you check via developer mode, you can see the response back from server is perfect. depending on what you are doing.. one alternative is to use iframe. load the html via it then get the content from it
|
|
|
|
cubiclecarbonate
|
Jan 3 2019, 09:43 AM
|
|
QUOTE(Grammar Police @ Dec 31 2018, 10:58 AM) I tried using jquery CODE $.ajax({ url: 'your-url', success: function(data) { alert(data); } });
but it wont work as the website is not on my domain hence web security blocked that. error code in chrome : Access to XMLHttpRequest at 'https://.xxx' from origin 'null' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. if php, maybe you can try something like simple html dom parser
|
|
|
|
olumis
|
Jan 6 2019, 11:35 AM
|
Getting Started
|
with client's browser, impossibru. You'll need to fetch the remote contents and complete the task on the server side first then only push the end result to the client.
|
|
|
|
koklimabc
|
Jan 8 2019, 09:02 AM
|
New Member
|
put the cross domain to avoid block,
$.ajax({ url: 'your-url', crossDomain: true, success: function(data) { alert(data); } });
|
|
|
|
TSGrammar Police
|
Jan 8 2019, 09:25 AM
|
|
QUOTE(koklimabc @ Jan 8 2019, 09:02 AM) put the cross domain to avoid block, $.ajax({ url: 'your-url', crossDomain: true, success: function(data) { alert(data); } }); wahhh can ar? later i try
|
|
|
|
ex.luffy
|
Jan 14 2019, 01:03 PM
|
New Member
|
QUOTE(Grammar Police @ Jan 2 2019, 03:59 PM) i dont have a server just me and my local machine. Use standalone local server.
|
|
|
|
brkli
|
Jan 18 2019, 03:32 PM
|
|
for production use, better to do a proxy (in your domain) to the remote server. any web server like nginx or apache can do it. you do not need to use any programming for this.
for testing, you can always disable browser cross origin checking.
|
|
|
|