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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T17:50:01+00:00 2026-06-13T17:50:01+00:00

$(document).ready(function() { $(‘#pricingEngine’).change(function() { var query = $(#pricingEngine).serialize(); $(‘#price’).fadeOut(500).addClass(‘ajax-loading’); $.ajax({ type: POST, url: index.php/welcome/PricingEngine,

  • 0
$(document).ready(function() {
    $('#pricingEngine').change(function() {
         var query = $("#pricingEngine").serialize();
         $('#price').fadeOut(500).addClass('ajax-loading');
         $.ajax({
             type: "POST",
             url: "index.php/welcome/PricingEngine",
             data: query,
             dataType: 'json',
             success: function(data)
             {
               $('#price').removeClass('ajax-loading').html('$' + data.F_PRICE).fadeIn(500);
               $('#sku').attr('value') = (data.businesscards_id);
             }
         });
    return false;
   });
});

Need to set #sku as value of a hidden form field (not sure if i am doing that correctly in the above jQuery code.

<input type="hidden" name="sku" id="sku" value="*/PUT VAR VALUE HERE/*" />

Also need to pass the F_PRICE to the #price div.

Console in Chrome shows the JSON response as:

[
 {
  "businesscards_id":"12",
  "X_SIZE":"1.75x3",
  "X_PAPER":"14ptGlossCoatedCoverwithUV(C2S)",
  "X_COLOR":"1002",
  "X_QTY":"250",
  "O_RC":"NO",
  "F_PRICE":"12490",
  "UPS_GROUND":"12000",
  "UPS_TWODAY":"24000",
  "UPS_OVERNIGHT":"36000"
 }
]

Yet I only get ‘undefined’ in the price box. What is the reason here?

  • 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-13T17:50:02+00:00Added an answer on June 13, 2026 at 5:50 pm

    The structure returned as JSON is an array [] containing one element which is the object {} you are targeting. Access it via its array index [0]

    // Access the array-wrapped object via its [0] index:
    $('#price').removeClass('ajax-loading').html('$' + data[0].F_PRICE).fadeIn(500);
    // Likewise here, and set the value with .val()
    $('#sku').val(data[0].businesscards_id);
    

    You could also .shift() the first element off the array and use that as you have it:

    // Pull the first element off the array, into the same variable
    // WARNING: Use a different variable if the array has multiple elements you need to loop over later.
    // You *don't* want to do it this way if the array contains multiple objects.
    data = data.shift();
    $('#price').removeClass('ajax-loading').html('$' + data.F_PRICE).fadeIn(500);
    $('#sku').val(data.businesscards_id);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

$(document).ready(function() { $(#ddlprod).change(function() { var pk= $(#ddlprod).val(); $.ajax({ url: ajaxprintdropdown.php, type: POST, data: 'pk='+pk,
$(document).ready(function(){ var page = window.location.hash; if(page != ){ $('a[href='+ page +']').addclass('selected'); pageload(page.replace('#/page/', 'pages/?load=')); }
$(document).ready(function() { redo(1); $(select).change(function () { var str = ; $(select option:selected).each(function () {
$(document).ready(function(e) { $('span#pijlr').click(function(e) { var slide = 500; var variable = $('#gallcont').css('left'); var urechts
$(document).ready(function() { $('#<%=ddlContinents.ClientID %>').change(function() { var element = $(this); var totalLength = element.children().length; if
$(document).ready(function(){ setInterval(function(){ $.ajax({ url: getLiveData.php, success: function(result){ $.each(result, function(i, result){ var t = $(table#insideTable);
$(document).ready(function () { $(#divHeader)) { $(this).hover(function () { $(this).find('#edit').show(); $(this).find('#spandate').removeClass(datetime); $(this).find('#spandate').addClass(edit); }, function ()
$(document).ready(function() { function countChecked() { var n = $(input:checked).length; $(div).text(n + (n <= 1
$(document).ready(function() { $('#content').html(''); $.ajax({ url:'data.json', dataType: json, success: function(data) { $('#content').append('<p>'+data.rank+'</p>'); } });}); In
$(document).ready(function() { $('#username').focus(function() { $(this).val(''); }) $('#username').blur(function() { var l = $(this).val.length; if (l

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.