Search in php cURL with jquery
Search in php cURL with jquery
function curl_download($Url){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $Url);
curl_setopt($ch, CURLOPT_REFERER, "http://www.example.org/yay.htm");
curl_setopt($ch, CURLOPT_USERAGENT, "MozillaXYZ/1.0");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
$output = curl_exec($ch);
curl_close($ch);
return $output;
}
$curl = curl_download('http://www.example.com');
<script>
$(function() {
var myhtml = "<?=$curl;?>";
});
</script>
这只是在我的网页上输出整个网站。而不是在Javascript中放入一个变量。
我想把它当作标准的HTML代码来操作。
谢谢。
我不知道这是否是实现这一目标的最佳方式。如果你将整个html结果存储在js变量中,javascript会因为多行和未转义的双引号和单引号而抛出错误。您可以将该函数用作服务器端端点,并通过js中的ajax调用它。Jquery将处理html响应(避免引号冲突和新行),您可以将结果用作成功回调的参数。
您需要转义HTML。也许通过json_encode
运行?它可以为您处理所有转义
相关文章:
- Replacing jQuery.bind with jQuery.on
- PHP $_GET with jQuery $.get call
- Rails 3 if statement with jQuery?
- Trouble with jquery .append
- Javascript setTimeout function with JQuery
- Like Unlike toggle button with jQuery's AJAX
- IE8 issue with jQuery attr()
- ltrim with jQuery?
- json foreach array of arrays with jquery
- Setting Javascript along with JQuery
- XML to HTML with jQuery
- JQuery.animate(): HTML5 annimation with JQuery
- Bootstrap Contact Form with jQuery Validation and AJAX
- HTTP GET request with JQuery
- JavaScript Date with jQuery Countdown
- iframe Fade Out/In with jQuery
- Knockout with jquery.tmlp
- HREF within an IFrame with JQuery
- Coloring tr with jQuery
- ajax post with jquery to mongodb