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,725
  • 3
  • 30
  • 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
  • 868,454
  • 176
  • 1,908
  • 1,964