Welcome Guest, Not a member yet? Register   Sign In
Codeigniter - How to reveal info after is password entered via ajax
#1

[eluser]design_shuffle[/eluser]
Hi,

I am working on a codeigniter site, the client has requested that the price columns in a datatable are hidden from view unless a user enters a correct password(which they will give out to clients over the phone).

The obvious way is to make the user login which then reveals a new table/page with prices included.

Can I achieve this via AJAX somehow?, i.e. a dialog box appears, the user enters a password, a request is sent and a new table loads with prices included?

I am a total rookie at Codeigniter, but I am learning everyday, please could someone point me in the right direction?

Thanks
Dan
#2

[eluser]bretticus[/eluser]
[quote author="design_shuffle" date="1277402692"]
Can I achieve this via AJAX somehow?, i.e. a dialog box appears, the user enters a password, a request is sent and a new table loads with prices included?[/quote]

Yep. The easiest way is to use the load function of JQuery. This is less than trivial if you are a CI rookie as you say. However, not too bad with a little bit of insight.

Here's the idea (how I'd do it.)...

Create a controller method/action/function that loads the table (you don't even need a view.) You can use the HTML Table library for this. When it doesn't receive POST variables with username and password, show the table w/o prices. When a username and password are POSTed and authenticated, show the table with the prices column. When the view loads (the one you already have,) use load() from JQuery to automatically load the table. Latch on to a "enter your password for prices" link on the view and when clicked, popup a div that allows user to enter username and password (or however you want to present this to the user, maybe it's inline and you latch on to the form.) load() has parameters to send POST data. Send the username and password and load the form again into the same div that encapsulates the table already.

Good luck!

Good jquery reference
#3

[eluser]design_shuffle[/eluser]
Thanks for your help bretticus, I will give this a go!




Theme © iAndrew 2016 - Forum software by © MyBB