我在我的代码中使用了一个简单的ajax函数,它在本地主机中工作,但是当我上传代码时它不起作用! 这是我的视图:
<script type="text/javascript">
function active(int)
{
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("frm_radio").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","<?php echo site_url("admin/groups/active_img/".$gallery_name."/".$gallery_id)."/"?>"+int,true);
xmlhttp.send();
}
</script>
和我的HTML代码:
<form id = "frm_radio">
.
.
.
<input type="radio" id="radio" name="active" value="'.$item -> id.'" onclick="active(this.value)"/>
.
.
.
</form>
在我的控制器中我有一个名为active_img
的函数function active_img($gallery_name, $gallery_id, $itemID) {
$name = $gallery_name . "_id";
$actived = $this -> gallery_model -> getitems(NULL, array("active" => 1, $name => $gallery_id));
$actived[0] -> active = 0;
$this -> gallery_model -> additem($actived[0], $actived[0] -> id);
$insert_vars["active"] = 1;
$this -> gallery_model -> additem($insert_vars, $itemID);
return true;
}
有一些单选按钮可以选择必须处于活动状态的图像,当调用函数active_img时,它会更改我的数据库中的某个值并返回true,它在我的localhost中工作但在服务器中它不起作用!当我调试我的代码时,我收到此错误:
GET http://example.com/admin/groups/active_img/products/4/10 500 (Internal Server Error) 4:146
active 4:146
onclick 4:183
XHR finished loading: "http://example.com/admin/groups/active_img/products/4/10".
答案 0 :(得分:0)
可能是php错误,原因在error_log
中解释。网站的根目录中是否有error_log
?其他地方是否有日志文件夹?原因将在那里详述。
如果您使用.htaccess
,请再次查看。