You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$.ajax({
type: 'GET',
url: '/company/ajaxGetClients/1',
dataType: 'json',
success: function(response) {
console.log(response); // Expecting this response logged in console.
},
error: function (a, e){
console.log(e); // This logs "parseerror".
}
})
CompanyController
public function ajaxGetClients($id)
{
return response(Company::findOrFail($id)->clients->toArray()); // versions without toArray() or with toJson() also does not work. response()->json() same result.
}
As you can see, response is missing ending bracket ] making json invalid and ajax fails to parse it. Tried 3 browsers and Devtools Network panel shows same response. Laravel version 9.15.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
View
CompanyController
Response
As you can see, response is missing ending bracket
]
making json invalid and ajax fails to parse it. Tried 3 browsers and Devtools Network panel shows same response. Laravel version 9.15.Beta Was this translation helpful? Give feedback.
All reactions