Im using cakePHP 2.2.1
I have a GoalsController that has an add action in it. This action saves posted data to Goals table.
Inside the add.ctp im using jQuery ajax method to post the form data to above said add action.
What i want is,
- ajax method posts form data to goals/add
- goals/add action saves data to goals table
- Obtain the id of newly inserted row using $this->Goal->id
- Return this id back to the onSuccess function of ajax method
Steps 1,2,3 are working fine. But i dont know how to implement step4.
I know php is server side and js is client side and all. Is there anyway i can achieve this?