PHP CODE(plan-api.php)
$requestUrl = "url.com";
$response = (file_get_contents($requestUrl, false, $context));
$data = (json_decode($response, true));
echo $data["data"][0][recharge_amount];
echo "<br>";
echo $data["data"][0][recharge_talktime];
echo "<br>";
echo $data["data"][1][recharge_amount];
echo "<br>";
echo $data["data"][1][recharge_talktime];
echo "<br>";
echo $data["data"][2][recharge_amount];
echo "<br>";
echo $data["data"][2][recharge_talktime];
echo "<br>";
HTML/AJAX CODE(plan-ajax.php)
Please enter a Mobile number
<input type="text" id="search">
<br>
<input type="text" id="result">
<input type="text" id="result1">
<input type="text" id="result2">
<input type="text" id="result3">
<script>
$(document).ready(function() {
$('#search').keypress(function(){
$.ajax({
type: "GET",
url: "plan-api.php",
data: 'result=' + $('#search').val(),
success: function(output){
$('#result').val(output);
}
}); // Ajax Call
}); //event handler
}); //document.ready
</script>
OUTPUT(all in textbox having id "result")
10
7.77
20
15.54
30
23.32
but i want to get output :echo $data["data"][0][recharge_amount]
in textbox id "result"echo $data["data"][1][recharge_amount]
in textbox id "result1"echo $data["data"][2][recharge_amount]
in textbox id "result2"
and so on....