JavaScript JSON function failing to show

I apologize for my limited knowledge on this matter...

We are currently facing an issue with our website's pricing page. The dynamic calculator, which should display the price based on user input of size width and quantity, is not functioning as expected. Despite the script seemingly calculating the price correctly, it does not show up.

If anyone could assist me in identifying where I might be making a mistake, I would greatly appreciate it :-(

Interestingly, when I debug the console, all the information appears correct, yet it still fails to display!!!

Please note that the JavaScript responsible for outputting the price is provided below:


    <script>
$(function() {
    $('#inputqty').keyup(function() {
        var inputqty = $('#inputqty').val();
        var sku = $('#selSKU').val();
        $.getJSON('pricecheck.cfc?method=getPrice&returntype=JSON&sku='+sku+'&qty='+inputqty, function(data) {
            $("#divPrice").html(data.displayPrice);
        });
    });

});

    function qtyChanged(){
        var inputqty = $('#inputqty').val();
        var sku = $('#selSKU').val();
        $.getJSON('pricecheck.cfc?method=getPrice&returntype=JSON&sku='+sku+'&qty='+inputqty, function(data) {
            $("#divPrice").html(data.displayPrice);
        });


    };
</script>

Answer №1

Seems like there's an issue with the results retrieved from

http://www.xxxxxxxx.co.uk/pricecheck.cfc?method=getPrice&returntype=JSON&sku=2947&qty=7
.

The JSON data is prefixed with a comment indicated by double slashes.

Furthermore, it appears that if the JSON contains a syntax error, the $.getJSON function will fail silently. A discussion on this can be found at: Why does $.getJSON silently fail?

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Failed to make a request to https://registry.npmjs.org/node-modules because of an error: error:0906D06C:PEM routines:PEM_read_bio:no start line

Encountering an issue while attempting to install a JS package. Despite conducting thorough research, I have not been able to resolve the error. Please help me identify where I am going wrong. npm ERR! request to https://registry.npmjs.org/node-modules ...

Get a Blob as a PNG File

Hope you had a wonderful Christmas holiday! Just to clarify, I am new to JS and may make some unconventional attempts in trying to download my Blob in PNG format. I am facing an issue with exporting all the visual content of a DIV in either PDF or image ...

What are the different ways you can utilize the `Buffer` feature within Electron?

When attempting to implement gray-matter in an electron application, I encountered the error message utils.js:36 Uncaught ReferenceError: Buffer is not defined. Is there a method or workaround available to utilize Buffer within electron? ...

How does the onclick event trigger even without physically clicking the button?

I am struggling with creating a simple button using mui. My intention is to activate a function only when the button is clicked, but for some reason, as soon as I enter the webpage, it triggers an alert automatically. This behavior is puzzling to me and ...

transmitting data in JSON format through an HTTP URL

I have successfully implemented data transmission from my Android app to a REST Service using asp.net web api. The URLs I am sending, such as , are being processed in the web.api. Now, in the Android client, I am using GSON to convert a complex object in ...

Delete items within the first 10 minutes of shutting it down

Is there a way to temporarily remove a newsletter element for 10 minutes after closing it on a webpage? The idea is that once the panel is closed, it should stay hidden even if the page is refreshed within that timeframe. I was considering using local stor ...

Cannot locate element using React Testing Library with the selector: [data-testid="task"]

I've encountered an issue while testing a Task component that should be rendered after submitting a form. I'm utilizing redux-toolkit, but despite setting data-testid="task" for the Task component, it doesn't appear in the test DOM ...

How to incorporate a new attribute into a JSON object in node.js

In my quest to enhance a JSON file, I aim to add new fields that are distinct from the existing ones. The structure of the JSON is as follows: objJson={ istructor_id:"12345", student_id:"333", date: "2022-10-5" } I have tw ...

How can I retrieve the initial IP address from the 'X-Forwarded-For' using a Log Insight Query?

Can someone help me with extracting the initial IP address from the given data: X-Forwarded-For":"1.1.1.1, 2.2.2.2? This is the query I am currently using: fields @timestamp, @message | filter @message like /Endpoint request body after transform ...

Implementing Bootstrap 4 validation within a modal using JSON data

I've been struggling to validate the TextBoxFor before submitting the form. Despite trying various methods, I haven't managed to make it function properly. Modal: <div class="modal fade" id="MyModal_C"> <div class="modal-dialog" st ...

When the HTML and PHP code keeps running, the JavaScript text on the page updates itself

I was experimenting with threading in different languages like Java, PHP, and JavaScript. I am aware that JavaScript is single-threaded and PHP lacks robust threading capabilities. Below is the code snippet I have been working on: <body> <p id= ...

Finding the root cause of the error message 'Unexpected character: :' from using rjson

My company recently acquired a JSON data set, and I need to extract specific information from it. However, when attempting to import the data using the "fromJSON" method, I encountered an error as described in the title. With over 16,000 files worth of d ...

Can you provide instructions on how to replace the icon within the TablePagination element in MUI?

I'm currently working on a React project where I've implemented the MUI component known as TablePagination This TablePagination component is situated within the Table component, just like in the image provided below. https://i.stack.imgur.com/B ...

Is there a secure way to prevent user input from causing issues in a BigQuery node insert? Can the BigQuery.insert node library support parameterized queries for added security

I am seeking advice on how to securely insert user form data into BigQuery using the Google Cloud BigQuery library. Specifically, I am curious about the most effective methods for sanitizing, escaping, and cleaning the input data. Is it feasible to implem ...

Convert HTML code into a customized JSON structure

Is there a way to convert HTML into a specific JSON object? For instance This HTML page is well-structured (originally in markdown). I am interested in creating a JSON version of the different sections present on the page. In this scenario, every "h2" s ...

Ensure that the submit button triggers the display of results with each click

My project involves two navigation bars, each with its own table displayed upon page load. Additionally, there is a search bar used to display search results in another table. The issue I'm encountering is that when I click the submit button once, th ...

Reactjs implemented with Material UI and redux form framework, featuring a password toggle functionality without relying on hooks

Currently, I am working on a react project where I have developed a form framework that wraps Material-UI around Redux Form. If you want to check out the sandbox for this project, you can find it here: https://codesandbox.io/s/romantic-pasteur-nmw92 For ...

Struggling to transfer information from JavaScript to Python Flask?

I am currently working on a basic configuration where I need to send a string to my Flask application through Ajax, but unfortunately, I am encountering Error code 400: Bad request. Here is the JavaScript code snippet: headers = { 'Content-type&a ...

Send various pieces of information using Jquery/Ajax

I have encountered a challenge with my script - it currently only sends one value to the requested URL, but I now need it to handle two values. Unfortunately, I haven't been able to figure out how to do this. Each checkbox on the page is paired with ...

Cannot locate module using absolute paths in React Native with Typescript

I recently initiated a new project and am currently in the process of setting up an absolute path by referencing this informative article: https://medium.com/geekculture/making-life-easier-with-... Despite closely following the steps outlined, I'm en ...