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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T00:06:09+00:00 2026-06-18T00:06:09+00:00

I am using the themoviedb.org API which provides JSONP API that returns data for

  • 0

I am using the themoviedb.org API which provides JSONP API that returns data for films etc.

Am trying to create a form that you can search a film and it will return 5 most relevant movie titles based on the query.

Currently I am using:

           success: function(parsed_json) {
               console.log(parsed_json);

               $(".search").append("<li data-id=" +parsed_json["results"]["0"]["id"]+ ">" + parsed_json["results"]["0"]["original_title"] + "</li>");
               $(".search").append("<li data-id=" +parsed_json["results"]["1"]["id"]+ ">" + parsed_json["results"]["1"]["original_title"] + "</li>");
               $(".search").append("<li data-id=" +parsed_json["results"]["2"]["id"]+ ">" + parsed_json["results"]["2"]["original_title"] + "</li>");
               $(".search").append("<li data-id=" +parsed_json["results"]["3"]["id"]+ ">" + parsed_json["results"]["3"]["original_title"] + "</li>");
               $(".search").append("<li data-id=" +parsed_json["results"]["4"]["id"]+ ">" + parsed_json["results"]["4"]["original_title"] + "</li>");
               $(".search").append("<li data-id=" +parsed_json["results"]["5"]["id"]+ ">" + parsed_json["results"]["5"]["original_title"] + "</li>");
           }

to append all movie titles with data-id = the movie id. This seems to be ALOT of coding and I was wondering whether there is a way I could use each() to append the first 5 relevant movie titles.

Info on the JSONP API: http://help.themoviedb.org/kb/api/jsonp

Working JSFiddle: http://jsfiddle.net/javascript/5ApuF/

EDIT:

I have tried:

success: function(parsed_json) {
    var textToInsert = [];
    var i = 0;
    var length = parsed_json.length;
    for (var a = 0; a <length; a += 1) {
        textToInsert[i++]  = '<li>';
        textToInsert[i++] = parsed_json[a];
        textToInsert[i++] = '</li>' ;
     
    }
    $('.search').append(textToInsert.join(''));

}
  • 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-18T00:06:10+00:00Added an answer on June 18, 2026 at 12:06 am

    I believe something like this should work just fine for your needs…

    success: function(parsed_json) {
        console.log(parsed_json);
        if (k > 4) {
            return false;
        }
        $.each(parsed_json["results"], function(k, v) {
             $(".search").append("<li data-id=" +v["id"]+ ">" + v["original_title"] + "</li>");
        });
    }
    

    Goodluck! I edited this because I forgot you wanted only 5 results 🙂

    –al

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

Sidebar

Related Questions

I'm using the themoviedb.org's API to retrieve information about films. It's returning this JSON
I'm using themoviedb.org API to fetch the movie info. This is the code I'm
I am trying to access movie info using themoviedb API as imdb seems like
I am trying to create a simple app for the iPad that with play
Using Trigger.io's barcode api in an application that only contains boilerplate HTML and the
Using CRM 4, I have an entity form that contains a tab with an
Using Apache Velocity Api we can combine Java objects (Lists, POJOs etc.) with a
using this http://bl.ocks.org/950642 we can see how to add images to nodes, the question
Hey all I'm using a MPMoviePlayerController and trying to catch my exception when there
using phpPgAdmin, I've tried to create a table in my database. But am getting

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.