0

I am including the following javascript code in my HTML , which in turn makes a reference to a php file for doing a backend job :

<script type='text/javascript'>
<!--//<![CDATA[
var partnerId = "100b70a8a2248717";
var siteId = "12418";
var m3_u =    (location.protocol=='https:'?'https://javascriptGetAd.php':'http://javascriptGetAd.php');
var m3_r = Math.floor(Math.random()*99999999999);
document.write ("<scr"+"ipt type='text/javascript' src='"+m3_u);
document.write ("?partner_id=" + partnerId);
document.write ('&amp;site_id=' + siteId);
document.write ('&amp;version=1.5');
document.write ('&amp;language=javascript');
document.write ('&amp;format=wap');
document.write ('&amp;cb=' + m3_r);
document.write ("'><\/scr"+"ipt>");
//]]>-->

Can I call javascriptGetAd.php from inside a javascript function in any other way without using document.write() as shown above ?

4
  • What does your php return? Javascript? Commented Nov 24, 2011 at 7:14
  • @biziclop ...yes...my php returns some data in javascript format Commented Nov 24, 2011 at 7:17
  • Maybe this way: unixpapa.com/js/dyna.html Commented Nov 24, 2011 at 7:21
  • 1
    You could probably make this an ajax call, but I don't see any value add for doing what your asking. This format is common for ad code and tracking software. Commented Nov 24, 2011 at 7:21

1 Answer 1

1

You can use AJAX for this purpose

    var xmlhttp;
    if (window.XMLHttpRequest)
        xmlhttp=new XMLHttpRequest();
    else
       xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");




  xmlhttp.onreadystatechange=function()
      {
      if (xmlhttp.readyState==4 && xmlhttp.status==200)
        {
         // Handle xmlhttp.responseText;
        }
      }
    xmlhttp.open("GET","javascriptGetAd.php",true);
    xmlhttp.send();
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.