I am using codeigniter. What i want to achieve is as follows.
I am on a page /profile/username (Controller profile, function username).
This function loads a view which has a submit button.
<input type=submit value=apple>
I then have a jquery file which has ajax processing such that when the submit button is clicked /profile/process_click (a private function) is called with $.post.
The function process_click in the controller profile calls a method function which inserts the value of the submit button into the database (in this case ‘apple’). Alongside this function needs to insert the username of the person on whos profile the link was clicked (in this case ‘username’).
So.. my question is, how do I pass username from my profile controller to my jquery file such that it can be passed to process_click by $.post?
I need a secure and safe and ideally not resource intensive way to do this..
Cheers
First of all, the process_click function cannot be private or you won’t be able to call it via Ajax.
Jquery post method has a callback function which is called when the PHP script returns an answer, so in your js file do:
in the php script: