Advertisement
Guest User

javascript POST

a guest
Oct 4th, 2015
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. have this in the head tag:
  2.  
  3. <script>
  4. var url = "www.google-analytics.com";
  5. var method = "POST /collect HTTP/1.1";
  6. var postData = "v=1&t=event&tid=UA-XXX&cid=XXX&ec=gameTest&ea=newTest&el=testCampaign&ev=1";
  7.  
  8. var async = true;
  9.  
  10. var request = new XMLHttpRequest();
  11.  
  12. request.onload = function () {
  13.  
  14.  
  15. var status = request.status; // HTTP response status, e.g., 200 for "200 OK"
  16. var data = request.responseText; // Returned data, e.g., an HTML document.
  17. }
  18.  
  19. </script>
  20.  
  21. and this in a test button:
  22.  
  23. <button id="button" href="#newGame" onclick="request.open(method, url, async);request.send(postData);">Please click2</button>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement