Support the ongoing development of Laravel.io →
Authentication Requests Database
Last updated 2 years ago.
0

What is the ajax call returning? (Developer tools -> network -> response)

Your ajax call is making a get request, which will return

Route::get('/', 'StartController@index');

which isn't returning json

You would need to update your javascript to make a post request or change your ajax route in routes.php to a get request

0

Thanks for replying, I made a few changes yesterday and managed to get the JSON data returned that i requested, although occasionally on page refresh i see a 500 (internal server error) Error in the console

firstly while testing - i removed the datatype from the ajax call and found i had somehow managed to return a complete html form back to my script lol.

i removed the slash from the ajax call (url:'update',)

then i changed the 2nd Route from POST to GET

Route::get('/','StartController@update');

then in the controller i changed the return to

return json_encode(array('test'=>'Hello'));

which worked - before changing it back to the result from the Test::all();

return $data;

it works but i don't understand the 500 (internal server error)??

Last updated 8 years ago.
0

musaugurlu said:

This podcast may be helpful to find an answer.

https://laracasts.com/series/learning-vue-step-by-step/episodes/10

Thanks - i missed that one, i tried his syntax substituting my data which give me a 500 (internal server error) every call also he doesn't use the session token in his example.

i had this running in codeigniter within minutes.....

I'm using Xampp for my tests and i have no php errors in the log and the apache log just shows the 500 message - no clues.

0

Can you post your routes.php, controller and view?

stephansps said:

Thanks for replying, I made a few changes yesterday and managed to get the JSON data returned that i requested, although occasionally on page refresh i see a 500 (internal server error) Error in the console

firstly while testing - i removed the datatype from the ajax call and found i had somehow managed to return a complete html form back to my script lol.

i removed the slash from the ajax call (url:'update',)

then i changed the 2nd Route from POST to GET

Route::get('/','StartController@update');

then in the controller i changed the return to

return json_encode(array('test'=>'Hello'));

which worked - before changing it back to the result from the Test::all();

return $data;

it works but i don't understand the 500 (internal server error)??

0

Sign in to participate in this thread!

Eventy

Your banner here too?

stephansps stephansps Joined 25 Apr 2016

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.