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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T05:00:16+00:00 2026-05-18T05:00:16+00:00

ok, i guess I need help ! I searched with every keyword I could

  • 0

ok, i guess I need help ! I searched with every keyword I could think off, but I still cant figure out, please help. Am more of a php guy, and I’ve just started with jQuery.

Basically, what I am trying to do is to send a jQuery post from a click function. And based on whatever is returned by my php function, show/hide 2 divs. My php function returns a “json_encode” array with 2 simple values, like such :

//==================PHP code ==================================

$message_for_user = "blah blah";
$calculatedValue = 1230;
$responseVar = array(
                    'message'=>$message_for_user,
                    'calculatedValue'=>$calculatedValue
                    );
echo (json_encode($responseVar));

//==================PHP code End ==================================

My javascript code is supposed to accept the values returned by php :

//==================Javascript code ==================================

$("div.calculator_result").click(function()
{
    $.post('myCalculator.php' ,{qid:itemID},function(response)
    {
        $("div.calculation_value").show(500).html(response['calculatedValue']);
        $("div#message_for_user").show(500).html(response['message']);
    }
}

//==================Javascript code End ==================================

Unfortunately, on the javascript side of my project, the divs are not updated with the values returned by my php functions …. where am I wrong? I hope I was clear in my question, if not, do let me know, and I shall provide any extra info required.

Another thing is that earlier, I was echo’ing only a single value, that is the calculated value (echo $calculatedValue), and everything worked fine, its only after I shifted to echo’in the json encode array that things dont work

  • 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-18T05:00:16+00:00Added an answer on May 18, 2026 at 5:00 am
    var json = $.parseJSON(response); alert(json.message);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Under a tight deadline and I know I can figure this out eventually but
I'm stuck on some trivial question and, well, I guess I need help here.
[Update:] i know the problem... but need help to resolve this. The issue is
I need some help with floating point numbers...please! Here's the thing, I have code
TL;DR: Need help calling a rule with a fact I´ve started out with Prolog,
I got stumbled upon this issue once and I guess I need some expertise
I need to guess the mime type with the purpose of fill the Content-Type
I guess this is a simple question. I need to do something like this:
I guess I'm really after an aid to help people who forget, Cruise Control
I need help to built regular expression for string which does not start with

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.