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

I would highly suggest you go to youtube and view some videos on jquery by jream he has some excellent videos on this subject. Or if you are new to JavaScript I would suggest taking some basic tutorials on that subject first.

Last updated 9 years ago.
0

I'm fairly competent with javascript, but I'm not sure how to pass the data to the view without it being accessible by anyone && be able to be manipulated.

0

JavaScript is client-side code not server side, any data - manipulation in javascript will need to be sanitized, otherwise cross-site scripting attack can happen. Field manipulation with JavaScript normally takes place in the view you're not passing stuff to the view. Watch those jream videos you will be surprised what you will learn. Start off very simple make a form with one and only one text field practice using javascript to change that text field from your name to hello your name.
If you are talking about an Ajax return from jquery that's a different ball game altogether still watch those videos.

Last updated 9 years ago.
0

Your Laravel routing and middleware / filters should take care of the allowed users, then you just echo or return the data as normal.

0

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.

I then want to use JavaScript (probably jQuery) to choose which rows to display, in which order and so on.

I was going to use jQuery .get() method on a URL like mysite.dev/data/books which would return a Json data set, the problem is that anyone will be able to access mysite.dev/data/books.

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.

0

the problem is that anyone will be able to access mysite.dev/data/books.

Not if they register and you authenticate them first.

Read up on authentication from the docs and laracasts.

Last updated 9 years ago.
0

But if I only allow the data to authenticated users, will my jQuery .get() method fail? As I am not accessing the page directly?

Last updated 9 years ago.
0

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?

Last updated 9 years ago.
0

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!

0

No probs :)

0

Domcsore said:

I'm fairly competent with javascript, but I'm not sure how to pass the data to the view without it being accessible by anyone && be able to be manipulated.

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.

0

security should be handled server side not on the client side.

0

Sign in to participate in this thread!

Eventy

Your banner here too?

Domcsore domcsore Joined 23 Apr 2015

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.