خرید بک لینک
Creating a mobile app for a project.

basically using the moviedb.org website.
I've got the API working and showing data in the console but I am trying to get it to show on the actual page.

The Image I have attached is a screenshot of the console info on the app. As you can see it is fetching a result but not showing on the page.

Could anyone help me out?
Click image for larger version. 

Name:	Screen Shot 2017-12-14 at 00.13.30.jpg 
Views:	7 
Size:	45.9 KB 
ID:	17668


This is the Javascript code that am using that is fetching data from the API


Code:

$(document).on('pageinit', '#home', function(){
// $(document).ready(function(){
        console.info('hi');
          var latestUrl = 'https://api.themoviedb.org/3/movie/latest?',
    singleUrl = 'https://api.themoviedb.org/3/movie/'
    mode = 'search/movie?query=',
    key = '&api_key=7b0b1d8b1253e2bbfcd5602f76c52fdb',
    latestId = 0,
    targetId = 0;
    $.ajax({
        url: latestUrl + key ,
        dataType: "jsonp",
        async: true,
        success: function (result) {
                console.dir(result);
            // ajax.parseJSONP(result);
            latestId = result.id;
            console.info(latestId);
            targetId = Math.floor(Math.random() * latestId);
            console.info(targetId); 
            callFilmId(targetId);
        },
        error: function (request,error) {
            alert('Network error has occurred please try again!');
        }
    });
    // get random id


});


function callFilmId(tid){

$.ajax({
        url: "https://api.themoviedb.org/3/movie/"+tid+"?api_key=7b0b1d8b1253e2bbfcd5602f76c52fdb&language=en-US",
        dataType: "jsonp",
        async: true,
        success: function (result) {
            console.dir(result);
            if(result.status_code == 34){
                callFilmId(tid+1);
            }
            // ajax.parseJSONP(result);
        },
        error: function (request,error) {
          // alert('Network error has occurred please try again!');
            callFilmId(tid+1);
        }
    });


}


$(document).on('pagebeforeshow', '#headline', function(){
    $('#movie-data').empty();
    $.each(movieInfo.result, function(i, row) {
        if(row.id == movieInfo.id) {
            $('#movie-data').append('<li><img src="http://image.tmdb.org/t/p/w92'+row.poster_path+'"></li>');
            $('#movie-data').append('<li>Title: '+row.original_title+'</li>');
            $('#movie-data').append('<li>Overview <br>'+row.overview+'</li></br>');
            $('#movie-data').append('<li>Popularity : '+row.vote_average+'</li>');
            $('#movie-data').listview('refresh');
            $('#movie-data').append('<li>Release Date'+row.primary_release_year+'</li>');
        }
    });
});

$(document).on('vclick', '#movie-list li a', function(){
    movieInfo.id = $(this).attr('data-id');
    $.mobile.changePage( "#headline", { transition: "slide", changeHash: false });
});

var movieInfo = {
    id : null,
    result : null
}

var ajax = {
    parseJSONP:function(result){
        movieInfo.result = result.results;
        $.each(result.results, function(i, row) {
            console.log(JSON.stringify(row));
            $('#movie-list').append('<li><a href="" data-id="' + row.id + '"><img src="http://image.tmdb.org/t/p/w92'+row.poster_path+'"/><h3>' + row.title + '</h3><p>')
        })
        }
}

Thanks
Attached Thumbnails
Click image for larger version. 

Name:	Screen Shot 2017-12-14 at 00.13.30.jpg 
Views:	N/A 
Size:	45.9 KB 
ID:	17668  

برچسب: نویسنده: آیلین رضوانی تاريخ: جمعه 24 آذر 1396 ساعت: 7:56

صفحه بندی