So, I think I'm pretty close to the end, and now I need to add a series. As you can see, I have two bottoms where he says search for a movie and search for seri 
This means that I already have movies to work well, and now I stayed in the series. The problem is that I really donโt know how to make Javascript know that the buttom series is included, and then it should take my API and provide the information as is. I already have my JS for made films, which looks like this:
function callAjax(input) { var url = "http://localhost:1337/search/" + input; $.ajax({ type:'GET', url: url, success: function(data){ if(data) { console.log('SUCCESS'); $('#title').html("Title: " + data.title); $('#release').html("Release: " + data.release); $('#vote').html("Vote: " + data.vote); $('#overview').html("Overview: " + data.overview); $('#poster').html('<img src="' + data.poster + '" width=250 height=450 />'); $('#trailer').html("Trailer: <iframe width='420' height='315' src='https://www.youtube.com/embed/" + data.trailer + "' frameborder='0' allowfullscreen>"); $("#lblerror").addClass("hide"); } else { $("#lblerror").text("No movies were found!"); $("#lblerror").removeClass("hide"); } }, error: function(request, status, err){ console.log('ERROR'); } }); } $(document).ready(function(){ $('#submitButton').on('click', function(e){ e.preventDefault(); var input = $('#s').val(); callAjax(input); }); });
I can get the correct methods myself and so on. the only problem for me right now is that I canโt, or I donโt know how to do it, when her series, she should receive information from this URL: var url = " http: // localhost: 1337 / search / tv "+ input;
I hope I explained that this is understandable.
EDIT: my HTML looks like to make sure you know how you see it all.
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>MovieTrailerbase</title> <link rel="stylesheet" type="text/css" href="styles.css" /> </head> <body> <div id="page"> <h1>The MovieTrailer search</h1> <form id="searchForm" method="post"> <fieldset> <input id="s" type="text" /> <input type="submit" value="Submit" id="submitButton" /> <div id="searchInContainer"> <input type="radio" name="check" value="site" id="SearchMovie" checked /> <label for="SearchMovie" id="siteNameLabel">Search movie</label> <input type="radio" name="check" value="web" id="SearchSeries" /> <label for="SearchSeries">Search series</label> </div> </fieldset> </form> <div id="lblerror"></div> <aside> <div id="title"></div> <div id="release"></div> <div id="vote"></div> <div id="overview"></div> <br> <div id="trailer"></div> </aside> <div id="poster"></div> </div> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> <script src="script.js"></script> </html>
source share