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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T22:29:20+00:00 2026-05-20T22:29:20+00:00

Well I’ve managed to put the following together from various examples, however I don’t

  • 0

Well I’ve managed to put the following together from various examples, however I don’t believe the javascript function is even being called, below is all my code:

Javascript:

<script type="text/javascript" src="coding/jquery.js"></script>
<script type="text/javascript">

    function showHint(quantity, price){
     document.getElementById("txtcost").innerHTML="being called values" + quantity + price;
        $.getJSON('http://website.com/ecommerce/coding/validation/calprice.php', {q: quantity, p: price}, function(data){
            $('#txtcost').html('Total: ' + data.total);
            $('#txtvat').html('VAT: ' + data.vat);
        });

    }

</script>

Display

<span id="txtcost" style="color:#060"></span>
<span id="txtvat" style="color:#060"></span>

PHP

<?php
echo "being called";
function data() {
$q = $_GET["q"];
$p =&$_GET["p"];

$total = $p * $q;

if($q >= 10)
{
    $total = ($total / 10) * 9;
    //echo '<strong>£ ' . $total . '</strong><span style="font-size:10px; font-weight:bold;"> Discount applied.</span>';
    echo json_encode(array('total' => $total, 'vat' => '10.00'));
}
else{ echo '<strong>£ ' . $total . '<strong>'; }}
?>

Hope that helps

Note: the code isn’t perfect, I want to get the initial functionality working.

EDIT:

SO far I’ve managed to establish:

The function is being called
The correct values are being passed into the function

  • 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-20T22:29:21+00:00Added an answer on May 20, 2026 at 10:29 pm

    For one thing, you need to use JavaScript’s dot notation to reference object properties, and not PHP’s arrow operator:

    data.total
    

    instead of

    data->total
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Well, i have such-like code that prevent select all action from keyboard: $(document).keydown(function(e){ //
Well, my website can not redirect to https://www.facebook.com/QuaFootSpa from http://quafootspa.com/ I have tried redirection
Well, i took a break from RoR for studies, now I am back, I
Well, i want house image to rotate from -5° to 5° and i wrote
Well, merry christmas all! I am having trouble with the following whilst writing my
Well I'm looking for a function that reduce multiple space characters ' ' in
Well the title says it, I'm doing following kind of operations in Fortran: a(:,t)
Well I cant understand the above diagram of Von Neumann architecture [Cited from wikipedia]
well I havn't really ever using jquery to grab data from a server.. and
Well, can they? Like jQuery using a fadeIn function for something on a C++

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.