What could be the root cause of the "Uncaught SyntaxError: missing ) after argument list" error?

$(function(){
 $.getJSON("http://wallkeeper.com/wj/api/posts?s=" + document.getElementById("searchTxt").value, function(data){
    var template = $('#posts-list').html();
    var html = Mustache.to_html(template, data);
    $('#allposts').html(html);
    });
});

I am encountering an issue while trying to retrieve the search result JSON. The error message I am receiving is "Uncaught SyntaxError: missing ) after argument list". Can you please assist me in identifying where the problem lies?

Uncaught SyntaxError: missing ) after argument list

Answer №1

Forgot to include the + sign and unnecessary semicolon.

$(function () {
    $.getJSON("http://wallkeeper.com/wj/api/posts?s=" + document.getElementById("searchTxt").value+"", function (data) {
        var template = $('#posts-list').html();
        var html = Mustache.to_html(template, data);
        $('#allposts').html(html);
    });
});

Answer №2

Simply delete the "" following the value.

$(function(){
    $.getJSON("http://wallkeeper.com/wj/api/posts?s=" + document.getElementById("searchTxt").value, function(data){
        var template = $('#posts-list').html();
        var html = Mustache.to_html(template, data);
        $('#allposts').html(html);
    });
});

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

Unlocking the Power of HTML5 with Karma Launchers

No official documentation confirms or denies whether the karma launchers support HTML5 in browsers. Despite this, my tests are failing due to missing HTML5 capabilities in Firefox, Chrome, and PhantomJS. Interestingly, everything runs smoothly when using t ...

Learn how to handle JSON requests in Node.js within a router script

Hello everyone, I've been struggling to retrieve the body of a request from Postman into my scripts. The body always comes up empty. Can anyone help me figure out the correct way to do this? I have set up the server in index.js and reading the reques ...

Analyzing an HTTP response containing a Content-Type header specifying image/jpeg

Currently, I am developing my first web application and the task at hand involves loading an image from a database and sending it to the client for display. On the server side, I have the following code: res.setHeader('Content-Type', pic.mimetyp ...

Is this a legitimate HTTP request according to JQuery?

I have a specific http request that I need to implement. GET /deals/couchbaseDocument/_search { "query" : { "match" : { "amenities" : "Maids " } } } After successfully executing the request using curl, my goal is to de ...

I'm having trouble loading a Blender model in Three.js

I am a beginner in Blender and I have created a mesh using a bezier curve with version 2.70a. You can find the file here: When I export it to three.js format, only an empty shell is exported as shown in this link: http://pastebin.com/aVNnjE5f Exporting i ...

Error encountered when attempting to use regex in javascript with an invalid group

After coming across a regex that checks for multiple types of email address inputs, I encountered an issue while trying to use it in JavaScript. The error message "Uncaught SyntaxError: Invalid regular expression" kept popping up along with details about i ...

I have the ability to see HTTP-only cookies within my web browser

So, I always believed that httpOnly cookies could only be accessed during a http request. But the other day, while inspecting Firefox dev tools, I noticed that I could actually view the cookies' values. Is this standard behavior? ...

The express-fileupload throws an error saying "ENOENT: unable to locate the file or directory at 'public/images/name.ext'"

I am encountering an error ENOENT: no such file or directory, open 'public/images/name.ext from express-fileupload. I have searched for solutions to this issue, but none of the ones I found seem to work for me. Here are two examples: No such file or d ...

Bringing back a Mongoose Aggregate Method to be Utilized in Angular

I'm having trouble returning an aggregate function to Angular and encountering errors along the way. I would really appreciate some assistance with identifying the mistake I am making. The specific error message I receive is Cannot read property &apos ...

Update a div housing PHP code dynamically without needing to reload the entire webpage

I have a PHP script enclosed within a div that displays random text fetched from a file called random.txt. I am looking to automatically refresh this div every 15 seconds without reloading the entire page. I have come across various methods using AJAX or J ...

Update the table seamlessly to display fresh new data without the need to reload the entire page

I'm looking for a way to display recently added data on a listing page without having to reload the entire page. Currently, I have to refresh the page each time I add new data to my database in order to see the updates. Is there a way to view the new ...

React/Next Component Changes State and Clears it in useEffect

Currently, I am faced with an issue while attempting to fetch data from an API. The problem arises during the rendering process since the useEffect function is being called multiple times. Surprisingly, everything works perfectly fine during the initial pa ...

How can nextJS leverage async getInitialProps() method in combination with AWS S3?

I'm currently facing a challenge with executing an s3.getObject() function within an async getInitialProps() method in a nextJS project. I'm struggling to properly format the results so that they can be returned as an object, which is essential f ...

Having trouble implementing pagination for news-api in Vue.js2?

I am currently working on implementing a basic pagination feature in my Vue component specifically for the newsapi.org API. While my initial API call in the created hook is functioning as expected, I am encountering difficulties navigating to different pa ...

Unpacking jQuery's fancybox collection

Can anyone guide me to where I can locate the unpacked version of Jquery.fancybox-x.x.x.pack? I attempted to fix the code formatting manually in order to comprehend it better, but I'm still finding it challenging... ...

Setting up a Vue 3 parent component to emit events to a child component: a step-by-step guide

Seeking assistance with setting up a Vue 3 Tailwind parent component button to trigger a HeadlessUI transition event in a child component. The objective is for the button in the parent to emit an event, which the child will then watch for before triggering ...

JS unable to insert new row in table

I checked the input value before submitting it in the form and confirmed that it is correct, returning as a string.enter image description here const saveList = () => { const inputListNameText = inputListName.value; fetch('/api/lists' ...

Screen boundary bouncing effect upon reaching the edge

Currently, I am working on an animated project using canvas. I have successfully implemented the functionality to control the image (ship.png) with the arrow keys for different directions. However, I am facing challenges with creating a bounce effect when ...

Increasing the CPU usage of Chrome can be achieved by optimizing certain settings within the browser

Recently, I created an AI using NeroEvolution that plays the game of snake in p5.js. To enhance the training process, I am attempting to increase the number of game cycles per frame, but Chrome seems to be struggling to keep up with the demand. Is there ...

Is there any effort being made to utilize jQuery for the css @media screen and (max-width: 768px) function?

Is there a solution for handling the @media screen and (max-width: 768px) in CSS? I have created a responsive navigation bar, but when I change the display property of an element from none to block on mobile screens, it also appears on larger screens. Is ...