Get 2024 Templates Mega Bundle!14 Bootstrap, Vue & React Templates + 3 Vector Sets
Get for 99$

Laravel metronic Failure parsing JSON


I use Metronic V34 with laravel9 to manage a set of events. I manage to save the data in the database but to display them with the method response()->json() in the calendar it gives me this error:Failure parsing JSON someone can help me please
there is te controller method to display the data:
public function displayEvent(Request $request)
{
if($request->ajax())
{
$d = $this->event->GetEvent();
return response()->json($d);
}

}
and the view page to show the json data:
...
editable: true,
dayMaxEvents: true, // allow "more" link when too many events
events: {
url: "/display-events",
dataType:"json",
success: function(data, xhr) {
console.log('XHR success callback');

},
failure: function(xhr) {
console.log('XHR failure callback');
}
},
...


Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(

Replies (3)


Hi Sillien,

It seems like there's an issue with the JSON data being returned from the API endpoint. To debug the issue, you can try the following steps:

Check the response status code: You can check the XHR status code by using the following code in the "failure" function:

console.log(xhr.status);


Log the response data: You can log the data returned from the API endpoint by using the following code in the "success" function:

console.log(data);


This will give you an idea of what's wrong with the data and help you debug the issue. If the data is not in the correct format, you may need to modify the logic in your controller method to return the data in the correct format.

Thanks



thank you so much i find the solution now. thanks



Great! We're glad you were able to find a solution. Thank you for updating us. Have a wonderful day!


Your Support Matters!

We will highly appreciate your Metronic Review on Themeforest.
Please go to Themeforest Downloads page, select Metronic & leave your feedback.
Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(
Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(