Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/72.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript codeigniter中Uri结尾有slesh的HTTPRequest ajax错误_Javascript_Ajax_Codeigniter_Uri - Fatal编程技术网

Javascript codeigniter中Uri结尾有slesh的HTTPRequest ajax错误

Javascript codeigniter中Uri结尾有slesh的HTTPRequest ajax错误,javascript,ajax,codeigniter,uri,Javascript,Ajax,Codeigniter,Uri,帮助客人。。。 我使用frameworkcodeigniter和ajaxxmlhttp请求来从数据库加载一些数据 如果我像这样打开链接 localhost/web/topsales 一切都是这样。 localhost/web/topsales 但若我在url的末尾加上斜杠 localhost/web/topsales/ 结果是错误的。Ajax加载并复制页面视图,如下所示 我使用AJAX XMLHttp请求加载数据: function showdata() { var idu

帮助客人。。。 我使用frameworkcodeigniter和ajaxxmlhttp请求来从数据库加载一些数据

如果我像这样打开链接

  localhost/web/topsales
一切都是这样。

  localhost/web/topsales
但若我在url的末尾加上斜杠

localhost/web/topsales/
结果是错误的。Ajax加载并复制页面视图,如下所示

我使用AJAX XMLHttp请求加载数据:

function showdata()
{
    var idunit = document.getElementById('idunit').value;
    var month = document.getElementById('month').value;
    var year = document.getElementById('year').value;
    var xmlhttp;
    document.getElementById("result").innerHTML = "<div class='text-center'>Loading...</div>"; //xmlhttp.responseText
    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("result").innerHTML = xmlhttp.responseText; //xmlhttp.responseText
        }
    }
    xmlhttp.open("POST","showresult",true);
    xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
    xmlhttp.send("idunit="+idunit+"&month="+month+"&year="+year);
}
函数showdata()
{
var idunit=document.getElementById('idunit')。值;
var month=document.getElementById('month')。值;
var year=document.getElementById('year')。值;
var-xmlhttp;
document.getElementById(“结果”).innerHTML=“加载…”;//xmlhttp.responseText
if(window.XMLHttpRequest)
{//IE7+、Firefox、Chrome、Opera、Safari的代码
xmlhttp=新的XMLHttpRequest();
}
其他的
{//IE6、IE5的代码
xmlhttp=新的ActiveXObject(“Microsoft.xmlhttp”);
}
xmlhttp.onreadystatechange=函数()
{
if(xmlhttp.readyState==4&&xmlhttp.status==200)
{
document.getElementById(“结果”).innerHTML=xmlhttp.responseText;//xmlhttp.responseText
}
}
open(“POST”,“showresult”,true);
setRequestHeader(“内容类型”,“应用程序/x-www-form-urlencoded”);
xmlhttp.send(“idunit=“+idunit+”&month=“+month+”&year=“+year”);
}

请告诉我需要帮助,非常感谢您的建议。

您可能需要配置路由来处理这两个问题。我认为CodeIgniter将额外的/视为一条新路线。此外,我很惊讶看到IE5和IE6的支持。我们甚至不再支持IE9了。我已经配置了路由,还有.htaccess。。但是没有人在工作。它仍然像上面那样加载主页视图。。。不是我想要的来自数据库的数据。