$eventColored = DB::table('save_events')->get(['users_id','events_id']); return response()->json(['eventColored'=>$eventColored])->$eventColored = array('eventColored' => $eventColored );
I jak czytałem za pomoca ajaxa moge pobrac dane i przypisać je do zmiennej, dzieki ktorej bede mogl dopasowac kolor eventu. I tutaj jest pytanie jak przypisać dane do zmiennej, wydaje sie błache ale szczerze nie mam pojecia.
Kod
$.ajax({
type: "GET",
url: "{!!route('color')!!}",
dataType: "json",
data:{},
success: function(data)
{
var JSONString=data;
var JSONObject = JSON.parse(JSON.stringify(data));
console.log(JSONObject);
alert(JSONObject);
},
});
type: "GET",
url: "{!!route('color')!!}",
dataType: "json",
data:{},
success: function(data)
{
var JSONString=data;
var JSONObject = JSON.parse(JSON.stringify(data));
console.log(JSONObject);
alert(JSONObject);
},
});
Ogolnie pobiera mi dane i jak chce sobie sprawdzic allertem wyswietla prawidlowa ilosc tzn jak mam 2 elementy w tablicy to wyswietla mi 2 elementy w allercie ale niestety pokazuje "Object object". Kombinuje na różne sposoby lecz nic nie wychodzi.
Wynik w konsoli:
Object { eventColored: Array[1] }