Laravel API working in localhost but not worked in server while Request $request
Route:
Route::get(‘api/get-market-list’,’MemberTradesController@getMarketList’);
Route::get(‘api/get-market-list1′,’MemberTradesController@getMarketListtest’);
Controller :
public function getMarketListtest(Request $request){
$markets = DB::table("markets")
->pluck("market","id");
return response() -> json($markets);
}
public function getMarketList(Request $request){
$markets = DB::table("markets")
->where("exchange_id", $request->exchange_id)
->pluck("market","id");
return response() -> json($markets);
}
<title>Laravel 5 - Dynamic autocomplete search using select2 JS Ajax</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/css/select2.min.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/js/select2.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<script type="text/javascript">
$('#exchange').change(function(){
var exchangeID = $(this).val();
if(exchangeID){
$.ajax({
type:"GET",
url:"?exchange_id="+exchangeID,
success:function(res){
if(res){
$("#market").empty();
$("#market").append('<option>Select</option>');
$.each(res,function(key,value){
$("#market").append('<option value="'+key+'">'+value+'</option>');
});
}else{
$("#market").empty();
}
}
});
}else{
$("#market").empty();
$("#symbol").empty();
}
});
</script>
http://www.yourtradelog.com/api/get-market-list1
below URL is not fetching data so.. my javascript are not giving me result
http://www.yourtradelog.com/api/get-market-list?exchange_id=+1 (not working)
I want to know why this is not woring on server but all are working fine in localhost
**
ERROR LOG
**: 2 2: https://i.stack.imgur.com/rnPfh.png
from Laravel Questions and Answers https://laravelquestions.com/laravel/laravel-api-working-in-localhost-but-not-worked-in-server-while-request-request/
via Lzo Media
No comments:
Post a Comment