doulongdan2264 2019-01-31 12:57
浏览 82

为什么我的onClick函数显示“localhost / dashboard”?

I'm trying to show a list from database on my website. Actually the function is just an echo "hello". It's not a database problem.

So, when I press this button: https://imgur.com/a/x0QUZJe It shows http://localhost/dashboard/

I've debugged the project and when I press the button, it reaches to this file, loading localhost/dashboard/

I think something is wrong, I have another project where I add/delete and list users from a database, made by me, it works perfectly and when I debug it, it never loads this code. This project is like a copy-paste at the moment.

<?php
if (!empty($_SERVER['HTTPS']) && ('on' == $_SERVER['HTTPS'])) {
    $uri = 'https://';
} else {
    $uri = 'http://';
}
$uri .= $_SERVER['HTTP_HOST'];
header('Location: '.$uri.'/dashboard/');
exit;
?>
Something is wrong with the XAMPP installation :-(

This code refers to C:\xampp\htdocs\index.php

My another almost-identical project is working perfectly, is not receiving this error on onClick function.

HTML code:


<div id="caja" style="text-align: center">
    <input type="button" name="bMostrarCenso" id="bMostrarCenso" value="Mostrar censo" onclick="mostrarCenso()" class="boton"/>
    <div id="listado"></div>
</div>

mostrarCenso() is sent to this javascript file:

function mostrarCenso(){
   document.getElementById("listado").style.display='block'; 
    var xmlhttp;
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("listado").innerHTML = xmlhttp.responseText;
    }
}
xmlhttp.open("GET", "controladorVotantes.php?showCenso", true);
xmlhttp.send();

}

showCenso goes to controladorVotantes.php:


if (isset($_REQUEST['showCenso'])) { //MOSTRAR CENSO
    echo "hello"; 
}
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
    • ¥20 怎么用dlib库的算法识别小麦病虫害
    • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
    • ¥15 java写代码遇到问题,求帮助
    • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
    • ¥15 有了解d3和topogram.js库的吗?有偿请教
    • ¥100 任意维数的K均值聚类
    • ¥15 stamps做sbas-insar,时序沉降图怎么画
    • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
    • ¥15 关于#Java#的问题,如何解决?