我有这个jquery ajax函数:
$.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");
}
});
当我使用chrome和firefox时,它运行得非常好。但当我使用internet explorer时,它显示在控制台"1"中,但数据甚至没有插入数据库。
这是我在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;
}
您没有指定请求类型,因此它默认为GET,因此IE(很可能)正在缓存响应。添加
type: 'POST'
到您的AJAX配置对象,例如
$.ajax({
url: '/private_cloud/add_app/'+school_id+'/'+app_id,
type: 'POST',
// etc