Welcome Guest, Not a member yet? Register   Sign In
how to deal with chrome console warning "Resource interpreted as script but transferred with MIME type text/html" in cod
#1

[eluser]mi6crazyheart[/eluser]
Hey Guys, i dragged to a simple problem may be but don't know how to deal with it.

I'm on my way to build a chrome extension. The piece of jquery which i use in chrome extension is like this..

Code:
$.getJSON("http://localhost/CI/index.php/welcome/chromeExtension?jsoncallback=?",
    {format: "json"},function(data){
        for (var i in data)
        {
            //alert(data[i].ThreadID);
            [removed](data[i].ThreadAuthorFirstName + " : " + data[i].ThreadTitle );
        [removed]("<br />");
        }
});

My controller function is..

Code:
function chromeExtension()
{
        
    $this->load->model('home/welcome_page_model');
    $data = $this->welcome_page_model->latestThreadsForChromeExtension();
    echo json_encode($data);
            
}

But, right now i'm having strange warning from chrome consol & that is...

"Resource interpreted as script but transferred with MIME type text/html."

Dose any body have any idea how to deal with such kind of situation in codeigniter...
#2

[eluser]Krzemo[/eluser]
Code:
$this->output->set_header('Content-type: application/json');

EDIT:
Echoing things in controller is not best idea IMHO too. I'd pass it to a view...
#3

[eluser]mi6crazyheart[/eluser]
@Cshamoh used this. But, still no luck...

BDW, i'm also agree that echo in controller function is not a good idea. But, i don't know any other way to send JSON data to the chrome extension except this. Do u've any better idea... ?
#4

[eluser]Krzemo[/eluser]
To me “Resource interpreted as script but transferred with MIME type text/html.” clearly says that you have wrong headers set. I remember that in some cases CI $this->output->set_header('Content-type: application/json'); doesnt work (probably overriden by later headers setting).
I'm not sure what you are exaclty developing but if it were regular website you could use Firebug to check server response and its headers - that could give you a good hint.
#5

[eluser]mi6crazyheart[/eluser]
It's actually a google chrome extension. I've shown the chrome extension code in the 1st post.

The mechanism is, from Controller function "chromeExtension()" i'm trying send the JSON data to chrome extension & in the part of chrome extension it'll catch those JSON data & show in a HTML page...




Theme © iAndrew 2016 - Forum software by © MyBB