agustinvinao
New Member
- Messages
- 18
- Reaction score
- 0
- Points
- 0
Hi, im new in the host and i want to call de ads by ajax.
The javscript code is this:
Code for hosted_by.php:
In the page i add a span:
Functioning ok, but no resoult is display, i think is because the call is asynchronous and the javascript is not executed. The answer in the ajax response is this:
If you see in the <A> tag is emty in the text to show.
I like to do this because my site display slow because the call to de ads in a moment on high calls to this ads, i test this calls to a page with yhe ads and to other pages with no ads and the result is a difference in the load time. In the first test the page is view in the instant and the second test display in five second of load.
Sorry for my english but im argentine.
The javscript code is this:
HTML:
function CreateAjax() {
var xRequest=null;
if (window.XMLHttpRequest) {
xRequest=new XMLHttpRequest();
}else if (typeof ActiveXObject != "undefined"){
xRequest=new ActiveXObject("Microsoft.XMLHTTP");
}
return xRequest;
}
function GetHostedBy(){
try{
GetHTML(\'\hosted_by.php\',1,\'\',\'hosted\');
}catch(e){
}
}
function GetHTML(_url,_action,_parameter,_div){
// create obj ajax
var ajax = CreateAjax();
// get info
ajax.open(\'get\', _url+\'?\'+ _parameter);
ajax.onreadystatechange = function () {
if(ajax.readyState == 4){
var response = ajax.responseText;
document.getElementById(_div).innerHTML ="";
document.getElementById(_div).innerHTML = ajax.responseText;
}
}// end readystate
ajax.send(null);
delete ajax;
}
PHP:
<?php include('http://staff.x10hosting.com/adCode.php?ad=advanced');
HTML:
<span id="hosted"></span>
Functioning ok, but no resoult is display, i think is because the call is asynchronous and the javascript is not executed. The answer in the ajax response is this:
HTML:
<script language="JavaScript" type="text/javascript">
<!--
if (!document.phpAds_used) document.phpAds_used = ',';
phpAds_random = new String (Math.random()); phpAds_random = phpAds_random.substring(2,11);
document.write ("<" + "script language='JavaScript' type='text/javascript' src='");
document.write ("http://x10hosting.com/advert/adjs.php?n=" + phpAds_random);
document.write ("&what=zone:3&target=_blank");
document.write ("&exclude=" + document.phpAds_used);
if (document.referrer)
document.write ("&referer=" + escape(document.referrer));
document.write ("'><" + "/script>");
//-->
</script><noscript><a href='http://x10hosting.com/advert/adclick.php?n=a915c788' target='_blank'><img src='http://x10hosting.com/advert/adview.php?what=zone:3&n=a915c788' border='0' alt='' /></a></noscript>
I like to do this because my site display slow because the call to de ads in a moment on high calls to this ads, i test this calls to a page with yhe ads and to other pages with no ads and the result is a difference in the load time. In the first test the page is view in the instant and the second test display in five second of load.
Sorry for my english but im argentine.