I try to parse one page from my another site. For it i use cUrl
Request (send data to script):
$.ajax({
url: 'wordstat/ajax?query='+query+'&page='+page+'&id='+id,
success: function(data){
alert(data);
}
});
This script (wordstat/ajax), do request to my second site via controller:
Controller:
public function ajax()
{
$this->model->auth();
echo $this->model->parse_uri($_GET['page'],$_GET['query']);
}
Model:
public function parse_uri($url,$word)
{
curl_setopt($this->curl, CURLOPT_URL, "http://wordstat/rating.php?url=".$url."&word=".$word."&gap=3");
$html = mb_convert_encoding(str_replace("
","",curl_exec($this->curl)), "utf-8", "windows-1251");
preg_match('/<span style="font-size:14px" class=red>(.*)<\/span>/U',$html,$matches);
return $matches;
}
If i put in browser http://localhost/wordstat/ajax?page=page&url=url
and open this page, then
she return value of <span style="font-size:14px" class=red>
of another site correctly
But when i do it via Ajax request, it's always return empty Array
What i doin wrong? Sorry for bad english