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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T23:39:02+00:00 2026-06-08T23:39:02+00:00

i got an ajax function that calls a php who returns an array: <?php

  • 0

i got an ajax function that calls a php who returns an array:

<?php
$testing = array("one","two","three", "four");   
echo json_encode($testing);        
?>

i call it with this ajax call;

$.ajax({
url:"ajax_response.php",
type:"POST",   
success:function(msg)
{
  var array = msg;    
  var test = array[2];      
  alert(test);
}
});

the problem is that i want to get array[1] as “one” and im geting 1 character on every array position ex: array[0] = “o”, array[1] = “n”, array[2] = “e”. Its like the json encode or semething is spliting my array variables into characters.

Any help ??

Thanks in advance

  • 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-08T23:39:04+00:00Added an answer on June 8, 2026 at 11:39 pm

    You have to parse your answer. Easiest way would be to put a dataType to your AJAX call:

    $.ajax({
        url: "ajax_response.php",
        dataType: 'json', // add the dataType
        type: "POST",   
        success: function(msg) {
            var array = msg;    
            var test = array[2];      
            alert(test);
        }
    });
    

    Or you can parse it “by hand”. This is sometimes necessary:

    success: function(msg) {
        var array = JSON.parse(msg); // or parse it manually
        var test = array[2];      
        alert(test);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a an AJAX page request that uses a php file designed to
I've got a number of ajax calls that each triggers other ajax calls. I
I have an jquery ajax request that calls a PHP script that will send
I've got a checkout page which has some ajax calls that update hidden fields
I've got a click tracking AJAX function (calls a WebMethod on an .aspx page),
I did ajax call and got response in callback function like below: var v=;
I've got a bunch of Ajax links in a menu that reload a div
I got one controller called Profile with several function such as get_user_timeline and do_upload
I've got the following code: <script type=text/javascript> $(function(){ $(#AddMaps).submit(function(){ var $form = $('#AddMaps'); $.ajax({
I've got a simple $.ajax request that I am trying to fetch some HTML

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.