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

  • Home
  • SEARCH
  • 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 3962782
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T03:08:14+00:00 2026-05-20T03:08:14+00:00

So I’m building a web application and I have an ajax request that pings

  • 0

So I’m building a web application and I have an ajax request that pings a database (or database cache) and echos back a big thing of json. I’m totally new to json, and when the php pulls from the database I echo json_encode($databaseResults), then it shows up in my html page as a long string. My question is, how do I convert it and pull out the pieces I need into a nice format?

Thanks!

The Json result that was in the page looks like:

“[{\”currentcall\”:\”1\”,\”timecalled\”:\”15:30\”,\”etaTime\”:\”15:35\”,\”departmentID\”:\”1\”,\”memberID\”:\”1\”,\”callinnum\”:\”1\”,\”location\”:\”Fire House\”,\”billed\”:\”N\”,\”date\”:\”2\\/12\\/11\”,\”firstName\”:\”Phil\”,\”lastName\”:\”asdf\”,\”email\”:\”pasdf@gmail.com\”,\”homephone\”:\”+19111111111\”,\”cellphone\”:\”+11234567891\”,\”cellphone2\”:null,\”workphone\”:null,\”phonenumber5\”:null,\”phonenumber6\”:null,\”streetAddress\”:\”10 asdfnt Dr\”,\”city\”:\”\”,\”username\”:\”pgsdfg\”,\”password\”:\”0623ab6b6b7dsasd3834799fbf2a08529d\”,\”admin\”:\”Y\”,\”qualifications\”:\”Interior\”,\”rank\”:null,\”cpr\”:null,\”emt\”:null,\”training\”:null,\”datejoined\”:null,\”dateactive\”:null,\”state\”:\”DE\”,\”zip\”:\”51264\”,\”pending\”:\”NO\”,\”defaultETA\”:\”7\”,\”apparatus\”:\”asdKE-286\”}]”

There can be multiple results… this is only one result

EDIT:

Basically, I’m trying to pass a bunch of rows in an array into an html file, and take out only the data I need and format it. I don’t know if json is the best way to do this or not, just one solution I came up with. So if anyone has a better solution that would be awesome.

Edit2:
This is the jquery I have that makes the request, the php just has echo json_encode ($DBResults);

function getResponder(){
    var responders = $.ajax({
            type : "POST",
            url: "/index.php/callresponse/get_responders",
            success: function(html){
                $("#ajaxDiv").html(html);   
            }
    });

setTimeout("getResponder()", 10000);
}
  • 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-20T03:08:14+00:00Added an answer on May 20, 2026 at 3:08 am

    As you flagged this as jquery I assume that you’re using jQuery. If you’re only going to get the one string you can skip the json part and use jQuery .load() like this $('#result').load('ajax/test.php'); that will load the contents from ajax/test.php into #result

    However if you want to use json you can take a look over at getJSON on the jQuery documentation. You can also use the jQuery parseJSON function which will return the json an javascript object containing the jsonData.

    Here’s an example how you can use parseJSON

    var object = $.praseJSON(jsonString); //jsonString is the string containing your actual json data
    alert(object.location) //Will alert "Fire House" with the given json string
    

    Here’s an example of how you can use getJSON in the same way

    $.getJSON('ajax/test.php', function(object) {
      alert(object.location); //Will alert "Fire House" with the given json string
    });
    

    If you want to pass parameters as well you can do it like this

    $.getJSON('ajax/test.php', 
        { 
            Param1 : "Value1", 
            Param2 : "value2" 
        },
        function(object) {
            alert(object.location);  //Will alert "Fire House" with the given json string
        }
    );
    

    If you are trying to send json from javascript to php you can use

    $jsonArray = jsonDecode($_GET['key']); 
    

    Of course if you’re using post you’ll write $_POST instead.

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

Sidebar

Related Questions

No related questions found

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.