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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T11:30:53+00:00 2026-05-22T11:30:53+00:00

I am using the following code : $(document).ready(function() { $.ajax({ url: tiles/chartValue.php, datatype: ‘json’,

  • 0

I am using the following code :

$(document).ready(function() {
        $.ajax({
            url: "tiles/chartValue.php",
            datatype: 'json',
            type: 'POST',
            success: function(data){                
                $.each(data, function(key, value) { 
                  alert(key + ': ' + value); 
                });
                       });
                });

Here is chartValue.php

<?php
    include("../functions.php");
    $DAO=new DBUtil();
    $DAO->initDB("../db/connection.properties");
    $k=$DAO->getChart();
    echo json_encode($k);
?>

here is the getChart function of functions.php

public function getChart()
{
    $sql = "SELECT a.total, round( (b.active *100) / total ) active_user, round( (c.inactive *100) / total ) inactive_user
        FROM 
        (               
            SELECT IFNULL( count( * ) , 0 ) total FROM ashekan_info
        )a, 
        (               
            SELECT IFNULL( count( * ) , 0 ) active FROM ashekan_info WHERE is_active =1
        )b, 
        (               
            SELECT IFNULL( count( * ) , 0 ) inactive FROM ashekan_info  WHERE is_active =0
        )c";

        $result=mysql_query($sql,$this->connect()) or die(mysql_error());   
        $row = mysql_fetch_assoc($result);  
        $json = array('total'       =>$row['total'],
                  'active_user' =>$row['active_user'],
                  'inactive_user'   =>$row['inactive_user']
                 ); 
        return $json;

}

I get the result in firebug is {“total”:”1″,”active_user”:”0″,”inactive_user”:”100″}

problem is it shows each character in alert box. i.e : {, “, t and so on.

how can i get 1, 0, 100 ? 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-05-22T11:30:54+00:00Added an answer on May 22, 2026 at 11:30 am

    Just a guess…

    You have datatype: 'json', but JS is case sensitive, and the correct parameter is dataType. So it’s ignoring that, taking text, and your each call is iterating through characters of a string.

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

Sidebar

Related Questions

I am using following code to populate DropDown: $(document).ready(function(){ $('#inDistrict').sSelect(); $(#inDistrict).change(function(){ $.getJSON(filldistricts.php,{id: $(this).val(), ajax:
I'm using the following code.. $(document).ready(function(){ $(#test a).click(function(){ var labelTo = $(this).text(); window.location =
I have using the following code for developing tabs. $(document).ready(function() { $('#container-1').tabs(); } ....
Div box dimensions are measured using jQuery with following code: $(document).ready(function(){ var h =
I have the following block of code: $(document).ready(function(){ $(#form).submit(function(ev) { ev.preventDefault(); $.ajax({ type: POST,
I' m trying to enable adding/deleting rows to/from table using folowing code: Script: $(document).ready(function()
I have the following code that works: <script type=text/javascript> $(document).ready(function() { // Initialise the
I have the following code that works: <script type=text/javascript> $(document).ready(function() { // Initialise the
Setting onchange event for CheckBoxList using the following code doesn't work. chkListUserGroup.Attributes.Add(onchange, document.forms[0].isRecordModified.value='true';); How
I'm wondering if using the following Javascript code is reliable: if (!document.cookie) { alert('Cookies

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.