mycomputerguide
Dec 26th 2008, 1:19 pm
Hi folks,
I have a problem with which im strugling for two days now. I searched on Google but can't find a solution.
When I call the PHP file directly there are no problems, but when I call the PHP file through AJAX nothing happens because the site I'm trying to open with the PHP file() doesn't seem to be read. When I display the variable $rc in Ajax it displays 0. If anyone can give me a hint why I have this problem, I would be very very thankful. God bless & merry christmas!
Javascript code:
function createRequestObject() {
var ro;
var browser = navigator.appName;
if(browser == "Microsoft Internet Explorer"){
ro = new ActiveXObject("Microsoft.XMLHTTP");
}else{
ro = new XMLHttpRequest();
}
return ro;
}
var http = createRequestObject();
function sndReq(formname) {
var form = document.getElementById(formname);
var submitstring = "";
for(var i=0;i<form.length;i++) {
submitstring = submitstring + form.elements[i].name + "=" + form.elements[i].value + "&";
}
alert(submitstring);
http.open('get', 'retrieve.php?links='+submitstring);
http.onreadystatechange = handleResponse;
http.send(null);
}
function handleResponse() {
if(http.readyState == 4){
var response = http.responseText;
var update = new Array();
if(response.indexOf('|' != -1)) {
update = response.split('|');
document.getElementById(update[0]).innerHTML = update[1];
}
}
}
HTML code:
<form method="post" id="lb_form" action="">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td>
<textarea name="links" cols="50" rows="10"></textarea>
</td>
</tr>
<tr>
<td><input type="button" value="Retrieve related links" onclick="javascript:sndReq('lb_form');return false;"></td>
</tr>
<tr>
<td>
<div id="out"></div>
</td>
</tr>
</table>
</form>
Part of the PHP Code:
$alexac = preg_replace("@[\r\n]@", "", preg_replace($search,$replace,trim(implode('', file("http://www.*****.com/***/**/***/".$website."?page=1&q=link:".$website)))));
$rcount = preg_match_all("@1- 10of (.*?) linked to@mis", $alexac, $rcout);
$rc = floor(intval(str_replace(",","",$rcout[1][0]))/10);
I have a problem with which im strugling for two days now. I searched on Google but can't find a solution.
When I call the PHP file directly there are no problems, but when I call the PHP file through AJAX nothing happens because the site I'm trying to open with the PHP file() doesn't seem to be read. When I display the variable $rc in Ajax it displays 0. If anyone can give me a hint why I have this problem, I would be very very thankful. God bless & merry christmas!
Javascript code:
function createRequestObject() {
var ro;
var browser = navigator.appName;
if(browser == "Microsoft Internet Explorer"){
ro = new ActiveXObject("Microsoft.XMLHTTP");
}else{
ro = new XMLHttpRequest();
}
return ro;
}
var http = createRequestObject();
function sndReq(formname) {
var form = document.getElementById(formname);
var submitstring = "";
for(var i=0;i<form.length;i++) {
submitstring = submitstring + form.elements[i].name + "=" + form.elements[i].value + "&";
}
alert(submitstring);
http.open('get', 'retrieve.php?links='+submitstring);
http.onreadystatechange = handleResponse;
http.send(null);
}
function handleResponse() {
if(http.readyState == 4){
var response = http.responseText;
var update = new Array();
if(response.indexOf('|' != -1)) {
update = response.split('|');
document.getElementById(update[0]).innerHTML = update[1];
}
}
}
HTML code:
<form method="post" id="lb_form" action="">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td>
<textarea name="links" cols="50" rows="10"></textarea>
</td>
</tr>
<tr>
<td><input type="button" value="Retrieve related links" onclick="javascript:sndReq('lb_form');return false;"></td>
</tr>
<tr>
<td>
<div id="out"></div>
</td>
</tr>
</table>
</form>
Part of the PHP Code:
$alexac = preg_replace("@[\r\n]@", "", preg_replace($search,$replace,trim(implode('', file("http://www.*****.com/***/**/***/".$website."?page=1&q=link:".$website)))));
$rcount = preg_match_all("@1- 10of (.*?) linked to@mis", $alexac, $rcout);
$rc = floor(intval(str_replace(",","",$rcout[1][0]))/10);