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 4007760
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T08:40:15+00:00 2026-05-20T08:40:15+00:00

function getWriters(cat, lev, id) { if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome,

  • 0
function getWriters(cat, lev, id)   
{
    if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari
        xmlhttp = new XMLHttpRequest();
    }
    else { // code for IE6, IE5
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    xmlhttp.onreadystatechange = function() {
        if (xmlhttp.readyState == 4 && xmlhttp.status == 200)

        {

            document.getElementById("writer").innerHTML = xmlhttp.responseText;
            var writer = eval(xmlhttp.responseText);
            document.write(writer)
        }


    }

    xmlhttp.open("GET", "order.php?op=2&id=0&cat=" + cat + "&lev=" + lev, true);
    xmlhttp.send();


}

xmlhttp.responseText returns

Array ( [0] => Array ( [name] => Unassigned [user_id] => 2 [writing_level] => [writing_category] => ) [1] => Array ( [name] => arsalan [user_id] => 3 [writing_level] => [writing_category] => ) [2] => Array ( [name] => Shazia [user_id] => 4 [writing_level] => [writing_category] => ) [3] => Array ( [name] => janea [user_id] => 5 [writing_level] => [writing_category] => ) [4] => Array ( [name] => s [user_id] => 6 [writing_level] => [writing_category] => ) [5] => Array ( [name] => iuiui [user_id] => 8 [writing_level] => [writing_category] => ) [6] => Array ( [name] => demo [user_id] => 9 [writing_level] => [writing_category] => ) [7] => Array ( [name] => wewe [user_id] => 10 [writing_level] => [writing_category] => ) [8] => Array ( [name] => Muhammad Zoyeb [user_id] => 11 [writing_level] => [writing_category] => ) [9] => Array ( [name] => Atif Rauf Alvi [user_id] => 12 [writing_level] => [writing_category] => ) [10] => Array ( [name] => demo-1 [user_id] => 13 [writing_level] => [writing_category] => ) [11] => Array ( [name] => ffff** [user_id] => 14 [writing_level] => High School,Masters [writing_category] => Literature and Language,Social Sciences ) ) 

i am getting syntax error at document.write(writer);
if i remove eval() there is no syntax error.

Can anyone explain how to fix this or some other way to convert the string returned to array.

Thanks

  • 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-05-20T08:40:15+00:00Added an answer on May 20, 2026 at 8:40 am

    The string being returned from the server isn’t valid JSON or JavaScript syntax, so you can’t pass it to eval(). It looks like you’re using PHP’s print_r function on the array at the server — you need to use json_encode (PHP >5.2):

    echo json_encode($myArray);
    

    Then you can parse it locally with JSON.parse (recommended) or eval.

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

Sidebar

Related Questions

function loaded() { document.addEventListener('touchmove', function(e){ e.preventDefault(); }); myScroll = new iScroll('scroller'); } document.addEventListener('DOMContentLoaded', loaded);
Function Edit(ByVal id As Integer) As ActionResult Dim entities As New Deployment_devEntities() Dim w
function safe(){ if($(this).is(':checked')){ $(select[name='sort']).attr(disabled, disabled); $(input[name='group']).attr(disabled, disabled) } else { $(select[name='sort']).attr(disabled, false); $(input[name='group']).attr(disabled, false)
function dlLink(title, currentArray, currentIndex, currentOpts) { var img = new Image(); img.src = 'Gallery/Wallpapers/'
function returnsAnArray () { return array ('test'); } echo returnsAnArray ()[0]; generates a syntax
Function FillAdminAccount() As Boolean FillAdminAccount = True Try SQLconn.ConnectionString = connect timeout=9999999; & _
function Submit_click() { if (!bValidateFields()) return; } function bValidateFields() { /// <summary>Validation rules</summary> ///
function main() { Hello(); } function Hello() { // How do you find out
function AddTheatres() { Services.AdminWebServices.AddTheatresSVC(oTheatres, OnSuccessTheatres, OnError, OnTimeOut); } function OnSuccessTheatres(result1) { Services.AdminWebServices.AddTicketPricesSVC(oTicketPrices, OnSuccessTicketPrices, OnError,
function holiday_hitlist($tablename, $hit_user){ global $host, $user, $pass, $dbname; $link = mysql_connect($host, $user, $pass, $dbname);

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.