php - ajax with html issue -
i want html of website check links, use following ajax code html of remote website:
$.ajax({ type : 'get', url : 'proxy.php', datatype : 'html', success : function(data){ alert('success'); }, error : function(xmlhttprequest, textstatus, errorthrown) { alert('error'); } });
proxy.php proxy use data because not on server :
<?php // set return content type header('content-type: application/html'); // website url open $daurl = 'http://example.com'; // website's content $handle = fopen($daurl, "r"); // if there something, read , return if ($handle) { while (!feof($handle)) { $buffer = fgets($handle, 4096); echo $buffer; } fclose($handle); } ?>
the code alert error , can not understand ok because not expert ajax want check me? wrong ajax datatype? wrong header in proxy file please???
you serving html file retrieved proxy.php
wrong content-type
.
the right content-type should text/html
instead of application/html
.
if browse proxy.php
file see not getting content , browser tries download page.
after changing right content-type, if browse proxy.php
see contents in browser.
so, line you've change:
<?php // set return content type header('content-type: text/html');
Comments
Post a Comment