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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T21:55:22+00:00 2026-05-24T21:55:22+00:00

I’m trying to write a very simple autosuggest type function so that, whenever a

  • 0

I’m trying to write a very simple autosuggest type function so that, whenever a user enters a value into the search input, a list of matching results appear in below (In a ul with the id of playlist).

$("#ep_search").keydown(function() {

    var term = $("#ep_search").val();
        url = "includes/live_search.php?jsoncallback=&term=" + term;

    $.getJSON(url, function(data) {
        $.each(data.items, function(item){
            $("<li>").text(item.title).appendTo("#playlist ul");
        });
    });

});

Using chrome’s developer tools, I can see that I am getting back results:

([{"title":"Episode 4: Title"},{"title":"Episode 3: Title"},{"title":"Episode 2: Title"},{"title":"Episode 1: Title"}])

However, nothing is displaying on the page?

Am I missing something crucial here? I’m new to working with JSON requests.

  • 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-24T21:55:22+00:00Added an answer on May 24, 2026 at 9:55 pm

    Your url is wrong, so the server-response is missing the function-name.

    The response should look something like this:

    jQuery12345(yourJson)
    

    But by the wrong url there is no value for jsoncallback sended to the server(the value is generated by jQuery and the server should use it as function-name in the response)


    Use either:

    url = "includes/live_search.php?jsoncallback=?&term=" + term;
    

    (you’re missing the question-mark for jsoncallback)

    <?php
      //live_search.php 
       echo $_GET['jsoncallback'].'('.json_encode($someObject).')';
    ?>
    

    Or

    url = "includes/live_search.php?term=" + term;
    

    (you don’t need the jsoncallback-parameter, it’s not a X-Domain-Request. Let the server respond with the pure JSON)

    <?php
      //live_search.php 
       echo json_encode($someObject);
    ?>
    

    your $.each() should look like this:

    $.each(data, function(index,item){
                $("<li>").text(item.title).appendTo("#playlist ul");
            });
    

    (The first argument passed to the callback is the index, not the current item…what will be the 2nd argument)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I need a function that will clean a strings' special characters. I do NOT
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to create an if statement in PHP that prevents a single post
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
this is what i have right now Drawing an RSS feed into the php,

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.