Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

162
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!