Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8509387
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T03:25:15+00:00 2026-06-11T03:25:15+00:00

I keep getting an unexpected character error in the console for the line var

  • 0

I keep getting an unexpected character error in the console for the line

var a = JSON.parse(xmlhttp.responseText);

and I’m not sure why. Could this be why my textboxes aren’t populating with the parsed data?

Main page code:

function loadDoc()
{
   var xmlhttp;

   // code for IE7+, Firefox, Chrome, Opera, Safari
   if (window.XMLHttpRequest)
   {
      xmlhttp=new XMLHttpRequest();
   }
   // code for IE6, IE5
   else
   {
      xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
   }

   xmlhttp.onreadystatechange=function()
   {
      if (xmlhttp.readyState==4 && xmlhttp.status==200)
      {
         var doc = window.document.createElement("doc");
         var a = JSON.parse(xmlhttp.responseText);
         document.getElementById("textbox").innerHTML=a.first;
         document.getElementById("textbox2").innerHTML=a.second;
      }
   }

   xmlhttp.open("GET","loadTextBox.php?id=4",true);
   xmlhttp.send();
}

loadTextBox.php code:

<?php
---Placeholder for correct DB login info---

$result = $mysql->query(---Placeholder for correct SQL query---);

while ($row = $result->fetch_object())
{
   $queryResult[] = $row->present_tense;
}
$textboxValue = $queryResult[0];
$textboxValue2 = $queryResult[2];
echo json_encode(array('first'=>$textboxValue,'second'=>$textboxValue2));
?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T03:25:16+00:00Added an answer on June 11, 2026 at 3:25 am

    Your loadTextBox.php file should not contain any HTML because the JSON.parse method expects only JSON:

    <?php 
        header("Content-type: application/json");
    
        $db_username = placeholder; 
        $db_password = placeholder; 
        $db_host = placeholder; 
    
        $result = $mysql->query(---Placeholder for correct SQL query---);
    
        while ($row = $result->fetch_object())
        {
           $queryResult[] = $row->present_tense;
        }
        $textboxValue = $queryResult[0];
        $textboxValue2 = $queryResult[2];
        echo json_encode(array('first'=>$textboxValue,'second'=>$textboxValue2));
    ?>
    

    If your DB login info is in a separate file, then there should be no HTML or BODY tags only the PHP tags.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I keep getting the error Parse error: syntax error, unexpected T_STRING on line #9
Not sure what my problem is. On line 4 I keep getting an error.
I keep getting the following error: Parse error: syntax error, unexpected T_SL in /home/a4999406/public_html/willingLog.html
I keep getting a syntax error Parse error: syntax error, unexpected '{' in contact_form.php
I keep getting a Parse error: syntax error, unexpected ':', expecting ')' in /home/jobkill/public_html/process.php
here's the error I keep getting: Parse error: syntax error, unexpected T_DOUBLE_ARROW, expecting ')'
I keep getting a error saying unexpected token var on these lines var isSplash
Hey guys! I keep getting a syntax error (unexpected $end), and I've isolated it
Keep getting the error Arguments are not sufficiently instantiated for the multiplication by addition
I keep getting an error saying that @android:style/Widget.Holo.Light.Button.Borderless is not public and so can't

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.