Super Sale Limited Time 50% OFF for All-Access Plans
Save 50% Now

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
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(

Replies (3)


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.

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


Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(
Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(