Hi everyone,

Again, i am here for the second time. My current problem is kinda complecated for me. I am developing a project using Codeigniter framework for php. I am using SSE to display notification from a table in the database without user refreshing the page.

From a view (view1), it works fine. When i create another controller and a new view or sharing same view for the SSE part, it will show me this :

EventSource's response has a MIME type ("text/html") that is not "text/event-stream". Aborting the connection.

i already set this in my server side :

header('Content-Type: text/event-stream');
header('Cache-Control: no-cache');

also from view1, everything is working fine. Even if i am sharing a view (view_sse) with view1 and view2, view1 will work fine and view2 will show me this error :

EventSource's response has a MIME type ("text/html") that is not "text/event-stream". Aborting the connection.

May i know why? If needed, i can provide my code.

here is the SSE part :

//check for browser support
if(typeof(EventSource)!=="undefined") {
  //create an object, passing it the name and location of the server side script
  var eSource = new EventSource("db_polling");
  //detect message receipt
  eSource.onmessage = function(event) {
    //write the received data to the page
    var previous_message = document.getElementById("serverData").innerHTML;
    document.getElementById("serverData").innerHTML = "";
    document.getElementById("serverData").innerHTML += "<li class='child'><table>" + event.data + "</table></li>" + previous_message;

else {
  document.getElementById("serverData").innerHTML="Whoops! Your browser doesn't receive server-sent events.";
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.