I stuck here, already try other solution but no hope. I follow example in here, and resulting to this code :
<head>
<script>
var xmlhttp = new XMLHttpRequest();
var url = "";
var myArr;
var out = "";
var i;
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
myArr = JSON.parse(xmlhttp.responseText);
for(i = 0; i < myArr.length; i++) {
out += myArr[i].testing1 + myArr[i].testing2 + '<br>';
}
document.getElementById("allit").innerHTML = out;
alert(out);
}
};
xmlhttp.open("GET", url, true);
xmlhttp.send();
</script></head>
<body>
<div id="allit"></div>
</body>
Route::get('sogi', 'Sig@testing');
sig controller (case 1) :
public function testing()
{
$response = array('testing1' =>'success','testing2' => 'failed');
return response()->json($response);
}
sig controller (case 2) :
public function testing($route)
{
$check = Jalan::where('a', '=', $route)->toArray();
return response()->json($check);
}
But the result always blank even the alert box show blank, how to get JSON response from laravel single array like controller above (case 1) and (case2) if using eloquent?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire