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

174
Visualizações
Get the inline message of xhr responseText

I am receiving json form when submitting a contact form , and I would like to get the inline message of it ;

xhr.onreadystatechange = function() {
            if(xhr.readyState == 4 && xhr.status == 200) { 
               setFormMessage(xhr.responseText.) // Returns a 200 response if the submission is successful.
            } else if (xhr.readyState == 4 && xhr.status == 400){ 
                setFormMessage(xhr.responseTex)); // Returns a 400 error the submission is rejected.          
            } else if (xhr.readyState == 4 && xhr.status == 403){ 
                setFormMessage(xhr.responseText); // Returns a 403 error if the portal isn't allowed to post submissions.           
            } else if (xhr.readyState == 4 && xhr.status == 404){ 
                setFormMessage(xhr.responseText); //Returns a 404 error if the formGuid isn't found     
            }
           }

this the message when it's 200 :

{"inlineMessage":"Thanks for submitting the form."}

I have already tried to get the value of the inlineMessage like this :

xhr.responseText.inlineMessage 

but it didn't work ! any idea how to get that message

about 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

this xhr.responseText.inlineMessage is not working because you're treating the response data as an object , while it is JSON string

So you can parse that JSON string with a JavaScript program and access the data as an object. you might do something like this :

xhr.onreadystatechange = function() {
            if(xhr.readyState == 4 && xhr.status == 200) {
                const jsonResponse = JSON.parse(xhr.responseText)
               setFormMessage(jsonResponse.inlineMessage) // Returns a 200 response if the submission is successful.
            } 
about 4 years ago · Santiago Trujillo Relatório
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