This is my javaScript code :
$(document).ready(function() {
$('#IMDB').click(function() {
var MovieID = $('#MovieID').val();
$.post('action/action.php', { url: "http://api.themoviedb.org/3/movie/"+MovieID
+"?append_to_response=credits,images&api_key=myapikey" }, function(data) {
$("#test").html(data);
});
});
});
When I click the button I get imdb id from my input field which I inserted then I get the actual result from php. this is my php code.
<?php
$url = $_POST['url'];
$url2 = file_get_contents($url);
$json = json_decode($url2, true); //This will convert it to an array
$title = $json['original_title'];
$imdb = $json['imdb_id'];
echo $title;
echo $imdb;
return true;
?>
But I get result like this :
Batman: The Killing Jokett4853102
One is movie title and another is imdb id in same html tage. but I want to display my each result in each html tag like this :
$("#test").html(data); // result 1 -- movie title
$("#test2").html(data); // result 2 --- imdb id
Please help me how to get multiple value?
echo json_encode(array($title, $imdb));then use the object returned.