简体   繁体   中英

error 500 (Internal Server Error) with using ajax in codeigniter

I used a simple ajax function in my code and it's work in local host, but when I upload the code it did not work! This is my script in view:

    <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>

and my html code:

<form id = "frm_radio">
 .
 .
 .
 <input type="radio" id="radio" name="active" value="'.$item -> id.'"    onclick="active(this.value)"/>
 .
 .
 .
</form>

and in my controller I have a function with name 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;
    }

There are some radio button to chose what image must be active , and when called the function active_img , it change some value in my data base and return true, its worked in my localhost but in server it's not working! and when I debug my code I get this error :

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". 

It's likely a php error that the reason is explained in the error_log . Is there an error_log in the root directory of the web site? Is there a logs folder somewhere else? The reason will be detailed in there.

If you use .htaccess then check it again.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM