CodeIgniter Forums
Codeigniter - How to reveal info after is password entered via ajax - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Codeigniter - How to reveal info after is password entered via ajax (/thread-31569.html)



Codeigniter - How to reveal info after is password entered via ajax - El Forum - 06-24-2010

[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


Codeigniter - How to reveal info after is password entered via ajax - El Forum - 06-24-2010

[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


Codeigniter - How to reveal info after is password entered via ajax - El Forum - 06-24-2010

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