Search code examples
phpjavascriptencodeicalendar

How to encode an .ics header from JavaScript to PHP?


How can I post a JavaScript variable like the one below into a PHP script? (This is part of a .ics header):

var contents = "" +
'BEGIN:VCALENDAR' +
'\n' +
'VERSION:2.0' + 
'\n' + 
'PRODID:-// LIVEMEETING INTG//EN' +
'\n' +
'METHOD:CANCEL' +
'\n' +
'BEGIN:VEVENT' +
'\n' +
'UID:' + liveMeetingId + '@email.com' +
'\n';

Solution

  • It's a simple string. You can use AJAX to send it to a server-side script; the easiest way is via jQuery's $.ajax() method.