comebal
comebal

Reputation: 946

Error with Internet Explorer and Jquery Ajax

I have this jquery ajax function:

$.ajax({
    url: '/private_cloud/add_app/'+school_id+'/'+app_id,
    dataType: "json",
    async: false,
    success: function(data){
        if(data.status == 1)
        {
            console.log(data.status);
        }
    },
    error: function(error){
        alert("Error");
    }
});

When I am using chrome, and firefox, this is working perfectly fine. But when I am using internet explorer, it shows in the console "1" but the data wasn't even inserted in the Database.

This is my code in PHP:

public function add_app($school_id = NULL, $app_id = NULL)
{
    if($this->School->save($get_school))
    {
        echo '{"status":"1"}';
    }
    else{
        echo '{"status":"0"}';
    }

    die;
}

Upvotes: 0

Views: 857

Answers (1)

Phil
Phil

Reputation: 165059

You haven't specified a request type so it's defaulting to GET therefore IE is (most probably) caching the response. Add

type: 'POST'

to your AJAX config object, eg

$.ajax({
    url: '/private_cloud/add_app/'+school_id+'/'+app_id,
    type: 'POST',
    // etc

Upvotes: 1

Related Questions