Note that there are some explanatory texts on larger screens.

plurals
  1. PONeed to send data from one website to another asynchronously
    primarykey
    data
    text
    <p>My script tracks clicks on a client's page and uploads this to my server(let's call it .http://fancyclickserver23.net)</p> <p>Now I want the client to put a script on his site and this script will tag the clicks on the page and send the data to .http://fancyclickserver23.net on page leave or maybe even from time to time.</p> <p>I can't use Ajax because of cross browser restrictions, ofcourse. So how do I do this? I'll give a little hypothetical code to help you understand. I have a closure tracker which is loaded when the user puts </p> <pre><code>&lt;script src="http://fancyclickserver23.net/loadtracker.php?client_id=2332"&gt;&lt;/script&gt; </code></pre> <p>The code loads the closure tracker=function(){....}; The user needs to create an object of tracker</p> <pre><code>&lt;script&gt; track=new tracker(); track.init(); &lt;/script&gt; </code></pre> <p>track.init() basically binds a function that gets the Xpath of the element and stores it in track.clicks . Now i need to have a function track.send() which will send the clicks array as json(I know how to convert it to json) and send it on page close.</p> <p>How do I do this. Also I have seen some sites use something like:</p> <pre><code> document.write("&lt;sc"+"ript"+" src='https://fancyclickserver23.net/loadtracker.php?client_id=2332'"+"&gt;&lt;/scr"+"ipt&gt;"; </code></pre> <p>Why do this instead of a direct script tag? And why not put it in one string if we must use document.write() at all.</p> <p>So the two questions are:</p> <ol> <li>How do I send the data asyncronously(or otherwise) on page load?</li> <li>What does the above code do?</li> <li>I've seen Google analytics and Facebook do this, they don't seem to have any problems. Facebook infact renders the dialog box on screen. How?</li> </ol>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload