Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

287
Vistas
Getting a 404 error when when trying to run html page

I am trying to send over a string from PHP to a variable in JSON. But each time the page loads I get a 404 resource error for some reason. I don't understand what is happening and why I keep getting this error. I get the error after the webpage runs through the script part of the code. The way I check this out was using the dev kit in google chrome.

I'm running PHP through Microsoft IIS.

GettingFileInfo.php

<?php

    //Calls the getFileInfoMainFunction 
    getFileInfoMainFunction(); 



//Function      : sscaddir
//Parameters    : $dir
//Returns       : array
//Description   : This function takes an array where we get rid of the dots 
function sscandir($dir)
{
    return array_values(array_diff(scandir($dir),array('..','.'))); 
}

function getFileInfoMainFunction(){

        //variables
    $implodedFilesEqual;
    $toJson; 

    //C:\localwebiste\holmes-e-joesph-r
    $fileDirectory=dirname(__FILE__); 
    //now we are in the MyFilesDirectory
    $fileDirectory.="\MyFiles"; 

    //store all the files in the filedirectory in an array 
    $files=sscandir($fileDirectory); 

    //The '|' delimter 
    //This is the string that we will send too the client side code. 
    $implodedFilesEqual=implode("|",$files); 

    //For testing purpose 
    print_r($files);

    $toJson=json_encode($implodedFilesEqual); 

    

  
    echo ($implodedFilesEqual); 
     //Test.txt|test3.txt

}
?>

HTML page:

<html>
    <head>
        <title>Starting Page</title> 
        <link rel="stylesheet" href="StartPage.css" media="screen">
        <script src="https://ajax.googleeapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
        <script src="jQuery.js"></script>
    </head>
  
    <body id="theTextEditorsBody">

        <p id="demo"></p>
        <h1>Text Editor</h1>
        <hr> 
        <textarea id="textArea"></textarea>
        <br>

        <select>
            <option>textFile1</option>
            <option>textFile2</option>
            <option>textFile3</option>
        </select>
        <p id="hello"></p>

        
    </body>

jQuery.js:

const xmlhttp=new XMLHttpRequest(); 

xmlhttp.onload=function(){
    const myObj=JSON.parse(this.responseText); 

    document.getElementById("demo").innerHTML=myObj.name;

}

xmlhttp.open("POST","GettingFileInfo.php");
xmlhttp.send(); 
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda