I've got a block of code here that uses HTML 5 SSE
- the EventSource object, which lets a php script push updates to the webpage. However, I'm interested in also passing parameters to the script. How can I do that?
Here's the code:
if(typeof(EventSource) !== "undefined")
{
var source = new EventSource("get_message.php");
source.onmessage=function(event)
{
document.getElementById("message-window").innerHTML+=event.data + "<br>";
};
}
else
{
document.getElementById("message-window").innerHTML="Sorry, your browser does not support server-sent events...";
}
The closest thing I can think of is to use AJAX, as in
$.post("get_message.php", {largest_id: 30}, function(data, status){ some function });
However, I'm not sure how to write the jQuery for this?