If you are talking about an Ajax return from jquery that's a different ball game altogether still watch those videos.
Your Laravel routing and middleware / filters should take care of the allowed users, then you just echo or return the data as normal.
Sorry, I may not have explained myself all that great. I don't mean manipulate the data in the database. I'll try explain a little better.
I have my data in my database, say a books table.
I want to pass that all of the rows of the data to my view.
So, is the another way to pass data to my view where I am able to use the data with jQuery (nothing to do with the database) and not have it accessible to the world.
the problem is that anyone will be able to access mysite.dev/data/books.
Not if they register and you authenticate them first.
But if I only allow the data to authenticated users, will my jQuery .get() method fail? As I am not accessing the page directly?
Well, no, as the page which contains your jQuery get() will only be shown to authenticated users in the first place.
And even if the user tried to access your route without being authorised, your middleware would catch it and would return a 401 (Unauthorized) error.
You sound a little confused about some core back and front end concepts... perhaps you should be working through laracasts before going much further?
I think I'm getting it now... I was right in my thinking to begin with, the Json method that is. But you were right, I was (/ still slightly) confused as to why it works.
I have implemented my original way of thinking, just using the auth middleware on the DataController and it works as expected (or not expected haha!).
Thanks for the help davestewart!
No offense but if having to asked that question I still believe some more basics in jquery would only help you. Is there some reason you would not want to watch some free jQuery lessons from a very good instructor who's very knowledgeable?https://m.youtube.com/playlist?list=PL964151ECABC96679. I guess if you are not willing to watch free tutorials I guess you're just stubborn, sorry I bothered you.
Sign in to participate in this thread!
We'd like to thank these amazing companies for supporting us