Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

285
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda