0

I want to create a very primitive mixpanel/kissmetrics/analytics clone.

Therefor I need to send data to a remote website for the purpose of logging it. It should send simple parameters like, foo=bar, foo2=bar2

How can I send data with javascript without being caught to cross domain policy?
Can you provide an example code?

Herr
  • 2,715
  • 3
  • 29
  • 36

1 Answers1

0

Javascript can send arbitrary HTTP requests to any domain you like; you just cannot read the response.

To send a GET request, create an <img> element and set its src.

To send a POST request, create a hidden <form> that submits to a hidden <iframe>, then submit it.

SLaks
  • 837,282
  • 173
  • 1,862
  • 1,933